I am having difficulty reading/accessing cookies.
If a form element in my page is blank, in this case $passdir, I want to see if there is a cookie, then access a variable that says it has been written, $wrongdir, then overwrite the cookie with the new data in $wrong dir and print a header on the page. I want to test the value of $wrongdir and if it is a certain value, I will do a print statement based on that value.
Here is my code. Your assistance is great appreciated.
<?php
//created a function here...no big deal for my own use later on
function () { }
if ($passdir == "") {
if (!isset($wrongdir)) {
//wrongdir = the number of times an incorrect directory has been sent
$wrongdir = 1;
setcookie("wrongdir", $wrongdir);
print ("you didn't enter a directory");
}
else {
$wrongdir = $wrongdir + 1;
switch ($wrongdir) {
case 2:
print ("this is the second time you have supplied an incorrect directory");
// this is where I get an error "Warning: Oops, php3_SetCookie called after header has been sent in /home/httpd/lipperhosting.net/hd/new_traverse_directory.phtml on line 92"
setcookie("wrongdir", $wrongdir, time() + 300, "/", ".myurlheather.net", 0);
break;
case 3:
print ("this is the third time you have given an incorrect directory");
setcookie("wrongdir", $wrongdir);
break;
}
}
}
else {
if(!$dirid = @opendir($passdir.$dirrec)){
print " <dl class=\"error\"><dt>You didn't enter a valid directory.</dt><dd>Please try again.</dd></dl>";
// okay, here is where heather gets to dummy around and bake some cookies so that she can trace the history
// I get this error here "Parse error: parse error in /home/httpd/lipperhosting.net/hd/new_traverse_directory.phtml on line 113"
$wrongdir = $HTTP_COOKIE_VARS["wrongdir"]
if (!isset($wrongdir)) {
$wrongdir = 1;
setcookie("wrongdir", $wrongdir);
print ("this is the first time you have supplied an incorrect directory");
}
else {
$wrongdir++;
if ($wrongdir == 3) {
print ("this is the third time you have given an incorrect directory");
setcookie("wrongdir", $wrongdir);
}
if ($wrongdir == 2 {
print ("this is the second time you have supplied an incorrect directory");
setcookie("wrongdir", $wrongdir);
}
}
else {
fncLinkDir( $passdir, $recurse, $REQUEST_URI, $DOCUMENT_ROOT);
print("\n");
print("<head>\n");
print("<title>Recursive Directory Index</title>\n");
print("<link rel="stylesheet" href="style.css" type="text/css" --> \n"):
print("</head>\n");
print("<body>\n");
print "<h1>Index of ".$passdir. "</h1>";
}
}
?>
<hr>
</body>
Happy new year!
Thanks in Advance!
Heather