| | |
setcookies ()
![]() |
•
•
Join Date: Sep 2007
Posts: 60
Reputation:
Solved Threads: 0
just wanna ask..if session cant be use, i try setcookies() to get the variable pass through the pages, however i get this error message:
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\VertrigoServ\www\logincheck.php:2) in C:\Program Files\VertrigoServ\www\logincheck.php on line 3
i put setcookie($username, time()+3600); right after the mysql_connect(), and below it juz a normal function to differentiate between user and admin...
juz curious what is the mistake here and how can i declare the code? Thanks so much for helping..
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\VertrigoServ\www\logincheck.php:2) in C:\Program Files\VertrigoServ\www\logincheck.php on line 3
i put setcookie($username, time()+3600); right after the mysql_connect(), and below it juz a normal function to differentiate between user and admin...
juz curious what is the mistake here and how can i declare the code? Thanks so much for helping..
•
•
Join Date: Sep 2007
Posts: 60
Reputation:
Solved Threads: 0
hey..is you..hihi...
well, i setcookies() right after the user had logged in and the variables pass to the page shown below, i put it at the top right after <?php.....
well, i setcookies() right after the user had logged in and the variables pass to the page shown below, i put it at the top right after <?php.....
PHP Syntax (Toggle Plain Text)
<?php setcookie($username, time()+3600); mysql_connect("localhost", "root", "1234") or die(mysql_error()); mysql_select_db("userlist") or die(mysql_error()); $username=$_POST['username']; $password=$_POST['password']; $query = "SELECT * FROM user where username='$username' && password='$password'"; $result = mysql_query($query) or die(mysql_error()); if ($username=="admin" && $password=="admin1234") { echo "<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />"; echo "<center><h1>Administrator logged in!!!</h1></center>"; echo "<center><h1>Please wait to be directed to the administrator page.....</h1></center>"; echo "<meta http-equiv=\"refresh\" content=\"5;url=trytolink.php\">"; } else if(mysql_num_rows($result) > 0) { echo "<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />"; echo "<center><h1>You had sucessfully logged in as ".$username ."</h1><br/></center>"; echo "<center><h1>Please <a href='registration.php'>Click here</a> to update your details or <a href='claim_try.php'>Click here</a> to the claim page.</h1></center>"; } else { echo "<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />"; echo "<center><h1>Sorry! Your username and password is incorrect!!! Please try again!!!</h1></center>"; echo "<meta http-equiv=\"refresh\" content=\"5;url=index3.php\">"; } ?> <html> <head> <title>::. ISO CLAIM PAGE</title> <link rel="stylesheet" type="text/css" href="my.css"> </head> <body> </body> </html>
•
•
Join Date: Sep 2007
Posts: 60
Reputation:
Solved Threads: 0
oh..thanks, i not even notice about that also. So the cookies had been set with $username and timeout 1 hour.....Then from this page, i click to another page, using the same syntax for set cookies () declared at the top before any header or echo....and again i try to retrieve my username so that it can show on the page, however i found that it is blank.
Here is the code i use to show the $username out:
Here is the code i use to show the $username out:
PHP Syntax (Toggle Plain Text)
...... <form method="post" action="claim_try2.php"> <div><label>Name:<?php echo $_COOKIE["username"];?></label><br></div> <div><label for="type">Department:</label> <select name="department"> <optgroup label="---SELECT---"> <option>KKK</option> <option>KEE</option> <option>KPM</option>
![]() |
Other Threads in the PHP Forum
- Previous Thread: Anyone who can help?
- Next Thread: download from one server to another
Views: 1090 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for PHP
access ajax apache archive array arrays beginner binary box broken buttons cakephp cart check checkbox class classes cms code curl database date development directory display download dropdown drupal dynamic echo email error file files folder form forms functions header href htaccess html image include insert ip java javascript joomla jquery limit link list login loop mail menu mlm mod_rewrite multiple mysql order output parse password paypal pdf php problem query radio redirect regex remote results script search select server session sessions sort source sql string table tutorial update updates upload url user validation validator variable video web website wordpress xml






