SetCookie problem

From: Date: Wed, 01 Nov 2000 18:09:23 +0000
Subject: SetCookie problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-23202@lists.php.net to get a copy of this message
Can any one help me with the following piece of code. When I enter a valid user id and password, I get an error 'Ooops setcookie is called after sending a header' Thanks. <?php include("foo.inc") // contains nothing but the variable values and the validate_member function $id_link = @mysql_connect($host,$uid,$pwd); if($forgot==''): if($username!=''): $result=validate_member($username,$password,$id_link,$db); if($result==0): $id_link = @mysql_connect($db,$username,$passwd); $uidpwd=$username.'~'.$password.'~'.$id_link.'~'.$db.'~'; setcookie("uid",$uidpwd,time()+13600); echo '<meta http-equiv="refresh" content="0; url=admins">'; //later put header endif; endif; if($result>0 or $username == ''): echo "<html><body>"; switch($result){ case 1: echo "Invalid User ID<br>"; break; case 2: echo "Invalid User ID<br>"; break; case 3: echo "Bad Password<br>"; break; case 4: echo "You are not an Editor, Sorry<br>"; break; } echo '<b>Please enter your user name and pass word to procede..</b><br><br>'; echo '<form action="util.php3" method="post">'; echo '<table> <tr> <td>User Name</td>'; echo '<td><input type="text" name="username" value=""></td>'; echo '</tr> <tr> <td>Password</td> <td><input type="password" name="password" value=""></td>'; echo ' </tr> <tr> <td colspan="2">'; echo ' <input type="submit" value="Take me to Admin Page" name="submit" label="submit">'; echo ' <input type="submit" value="Forgot Password" name="forgot" label="forgot">'; echo ' </td> </tr></table></form></body></html>'; endif; endif; ?>

« previous php.general (#23202) next »