Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/84485-cookies-dont-register/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/84485-cookies-dont-register/#findComment-430440
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/84485-cookies-dont-register/#findComment-430445
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/84485-cookies-dont-register/#findComment-430470
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.