webtuto Posted January 4, 2008 Share Posted January 4, 2008 I have two login forms, one for admin, the other for members, I am using the same code for both with alternative SQL queries. The admin login works, whilst the member login doesn't. <?php include("config.php") ; if (isset($_POST['user']) && isset($_POST['password'])){ $user = $_POST['user']; $pass = $_POST['password']; $query = "select * from members where user='$user' and pass='$pass'" ; $result = mysql_query($query) ; $count = mysql_num_rows($result) ; if ($count == 1) { $timestamp_expire = time() + 365*24*3600; // Le cookie expirera dans un an setcookie('user', ($_POST['user']), $timestamp_expire); // On crit un cookie setcookie('pass', md5($_POST['password']), $timestamp_expire); // On crit un cookie echo '<meta http-equiv="refresh" content="0;url=user_p.php" />'; } else echo 'le pass ke vs aves etres est faux'; } else{ ?> <table border=0 ><caption>member login</caption> <form action="" method="post"> <tr><td><b>pseado</b><td><input type="text" name="user" ></tr> <tr><td><b>mot de passe</b><td><input type="password" name="password" ></tr> <tr><td><input type="submit" value="Entrer" ></tr> </table> <?php } ?> The errors returned are header errors, I've read the sticky too. I am not focused on security as of this moment. Quote Link to comment https://forums.phpfreaks.com/topic/84485-cookies-dont-register/ Share on other sites More sharing options...
webtuto Posted January 4, 2008 Author Share Posted January 4, 2008 UP UP UP Quote Link to comment https://forums.phpfreaks.com/topic/84485-cookies-dont-register/#findComment-430427 Share on other sites More sharing options...
PFMaBiSmAd Posted January 4, 2008 Share Posted January 4, 2008 You would need to post the error message for anyone to be able to help you. The specific error (we can probably guess) but which line the output is started on is important to finding exactly what is causing the problem. I will guess that it is line 1 of the posted file or if this file is being included into another file, it is some line of that other file. We only see the information that you post, and if you don't post all the information you see, such as exact error messages, it is just a game of 20 questions and it takes longer to solve the problem. Quote Link to comment https://forums.phpfreaks.com/topic/84485-cookies-dont-register/#findComment-430440 Share on other sites More sharing options...
webtuto Posted January 4, 2008 Author Share Posted January 4, 2008 Warning: Cannot modify header information - headers already sent by (output started at /home/www/webtutotest.freehostia.com/news/login.php:1) in /home/www/webtutotest.freehostia.com/news/login.php on line 13 Warning: Cannot modify header information - headers already sent by (output started at /home/www/webtutotest.freehostia.com/news/login.php:1) in /home/www/webtutotest.freehostia.com/news/login.php on line 14 Quote Link to comment https://forums.phpfreaks.com/topic/84485-cookies-dont-register/#findComment-430445 Share on other sites More sharing options...
PFMaBiSmAd Posted January 4, 2008 Share Posted January 4, 2008 Either there is white space (newline, space, tab...) before the <?php tag or the file is saved by your editor in UTF-8 encoding and the BOM (byte order maker) characters that are at the start of the file are being output to the browser. Check for any characters before the <?php tag and make sure the file is saved in ANSI/ASCII mode. Quote Link to comment https://forums.phpfreaks.com/topic/84485-cookies-dont-register/#findComment-430470 Share on other sites More sharing options...
mike1313 Posted January 4, 2008 Share Posted January 4, 2008 Also depending on your host/server etc. Make sure output buffering is on, that way you can send headers wherever possible. Quote Link to comment https://forums.phpfreaks.com/topic/84485-cookies-dont-register/#findComment-430482 Share on other sites More sharing options...
revraz Posted January 4, 2008 Share Posted January 4, 2008 Or fix the code. Also depending on your host/server etc. Make sure output buffering is on, that way you can send headers wherever possible. Quote Link to comment https://forums.phpfreaks.com/topic/84485-cookies-dont-register/#findComment-430485 Share on other sites More sharing options...
webtuto Posted January 4, 2008 Author Share Posted January 4, 2008 thanks it is fixed now Quote Link to comment https://forums.phpfreaks.com/topic/84485-cookies-dont-register/#findComment-430528 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.