I have been attempting for about the last 30 hours to get a login code that works made and I'm 1/2 way there and now I need help. I have this code:
<?php
$login = mysql_query("SELECT `user_id`, `username`, `password`, `email`, `status` FROM `users` WHERE `email` = '$_POST[email]' AND `password` = '$_POST[password]' LIMIT 1");
while($log = mysql_fetch_array($login ))
{
session_start();
$_SESSION['user_id'] = $log[user_id];
$_SESSION['username'] = $log[username];
$_SESSION['password'] = $log[password];
$_SESSION['email'] = $log[email];
$_SESSION['status'] = $log[status];
}
$result = mysql_query("SELECT `user_id`, `username`, `password`, `email`, `status` FROM `users` WHERE `email` = '$_POST[email]' AND `password` != '$_POST[password]'");
while($res = mysql_fetch_array($result ))
{
echo "Sorry you entered an incorrect password, please try again";
}
if($_SESSION['email'] == $_POST['email'])
{
if($_SESSION['password'] == $_POST['password'])
{
mysql_query("UPDATE `users` SET `status` = '1' WHERE `email` = '$_POST[email]' AND `password` = '$_POST[password]'");
}
else if($_SESSION['password'] != $_POST['password'])
{
echo "You entered an invalid password";
}
}
else if($_SESSION['email'] != $_POST['email'])
{
echo "You entered an invalid email";
}
?>And it will only work if there is 1 account in the database and of course the purpose of one account is nothing and [i]I cannot figure out why it only works with one account. If anybody can, could you tell me what needs to be done?