Cannot figure it out...


#1

Hi, I am having a problem with cookies/registration form. here is the code for cms_cookie.php:
[php]<?php
ini_set(‘display_errors’, 1);
ini_set(‘log_errors’, 1);
ini_set(‘error_log’, dirname(FILE) . ‘/error_log.txt’);
error_reporting(E_ALL);
// include ‘cms_includes.php’;
function show_cookie($first_name,$middle_name,$last_name,$address,$city,$state,$zip_code,$phone,$user_name,$password,$email,$last_visit) {
echo $first_name."
";
echo $middle_name."
";
echo $last_name."
";
echo $address."
";
echo $city."
";
echo $state."
";
echo $zip_code."
";
echo $phone."
";
echo $user_name."
";
echo $password."
";
echo $email."
";
echo $last_visit."
";
}
function write_cookie($first_name,$middle_name,$last_name,$address,$city,$state,$zip_code,$phone,$user_name,$password,$email,$last_visit) {
?>
<form action="<?php echo "fill_cookie.php"; ?>" method=“POST”>
First Name:
Middle Name:
Last Name:
Address:
City:
State:
Zipcode:
User Name:
Password:
Email:
Phone:
<input type=“hidden” name=“last_visit” value="<?php echo date("m/d/y"); ?>">

<?php } function cms_delete_cookie() { setcookie("first_name","",time()-1,"","192.168.1.2"); setcookie("middle_name","",time()-1,"","192.168.1.2"); setcookie("last_name","",time()-1,"","192.168.1.2"); setcookie("phone","",time()-1,"","192.168.1.2"); setcookie("address","",time()-1,"","192.168.1.2"); setcookie("city","",time()-1,"","192.168.1.2"); setcookie("state","",time()-1,"","192.168.1.2"); setcookie("zip_code","",time()-1,"","192.168.1.2"); setcookie("user_name","",time()-1,"","192.168.1.2"); setcookie("password","",time()-1,"","192.168.1.2"); setcookie("email","",time()-1,"","192.168.1.2"); setcookie("last_visit","",time()-1,"","192.168.1.2"); } if(isset($_POST['submit'])) { switch($_POST['choice']) { case "D" : //show_cookie($_POST['first_name'],$_POST['middle_name'],$_POST['last_name'],$_POST['address'],$_POST['city'],$_POST['state'],$_POST['zip_code'],$_POST['phone'],$_POST['user_name'],$_POST['password'],$_POST['email'],$_POST['last_visit']); break; case "C" : //write_cookie($_POST['first_name'],$_POST['middle_name'],$_POST['last_name'],$_POST['address'],$_POST['city'],$_POST['state'],$_POST['zip_code'],$_POST['phone'],$_POST['user_name'],$_POST['password'],$_POST['email'],$_POST['last_visit']); break; case "W" : //write_cookie($_POST['first_name'],$_POST['middle_name'],$_POST['last_name'],$_POST['address'],$_POST['city'],$_POST['state'],$_POST['zip_code'],$_POST['phone'],$_POST['user_name'],$_POST['password'],$_POST['email'],$_POST['last_visit']); break; case "E" : //cms_delete_cookie(); break } } else { ?> Cookie Manipulator <?php if(isset($_COOKIE['last_visit'])) { ?> Display Cookie
Change Cookie
Erase Cookie
<?php } ?> Write Cookie
<?php } ?> [/php] and the file fill_cookie.php: [php]<?php setcookie("first_name",$_POST['first_name'],time()+60*60*24*30,"","192.168.1.2"); setcookie("middle_name",$_POST['middle_name'],time()+60*60*24*30,"","192.168.1.2"); setcookie("last_name",$_POST['last_name'],time()+60*60*24*30,"","192.168.1.2"); setcookie("address",$_POST['address'],time()+60*60*24*30,"","192.168.1.2"); setcookie("city",$_POST['city'],time()+60*60*24*30,"","192.168.1.2"); setcookie("state",$_POST['state'],time()+60*60*24*30,"","192.168.1.2"); setcookie("zip_code",$_POST['zip_code'],time()+60*60*24*30,"","192.168.1.2"); setcookie("phone",$_POST['phone'],time()+60*60*24*30,"","192.168.1.2"); setcookie("user_name",$_POST['user_name'],time()+60*60*24*30,"","192.168.1.2"); setcookie("password",$_POST['password'],time()+60*60*24*30,"","192.168.1.2"); setcookie("email",$_POST['email'],time()+60*60*24*30,"","192.168.1.2"); setcookie("last_visit",$_POST['last_visit'],time()+60*60*24*30,"","192.168.1.2"); ?> [/php] I keep getting just one error, and it is Parse error: syntax error, unexpected '}' in /var/www/cms_cookie.php on line 67. I just do not know what is the problem! :'(

#2

Well, it is a closing bracket issue… But, which line is #67???


#3

The second function isn’t closed, neither is the last one. Also your cookies have to be deleted in the order they were written, with the same parameters - just a hint.


#4

richei,
I tried as you suggested, and it it gave me a syntax error, invalid ‘}’ at that line #. I don’t think I was wrong in my function declarations, either. I just cannot figure it out…
thanx ahead,
yours,
Jacques P. 8)


#5

case E - the break is missing the ;