PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am working on a multi-user login script where if a username and password number combination (specified in a MySQL database) is entered correctly, then users are to be redirected to the "congrats.php" page. However, with my current code, even with correct username + password input, the script does not work and instead of going to the "congrats.php" page, the login page (loginform2.php) just reloads :/
$sql = "SELECT COUNT(name) FROM users WHERE name = '{$name}' AND pass = '{$pass}'";
list($count) = mysql_fetch_row(mysql_query($sql));
// If you have more than one result, that's also a problem
if ($count == 1)
{
// You might want to set some session variables here, too.
header('Location:congrats.php');
}
else
{
echo "Invalid username and password combination";
}
Of course, you really shouldn't be using mysql_ functions either, but one thing at a time.
$sql = "SELECT COUNT(name) FROM users WHERE name = '{$name}' AND pass = '{$pass}'";
list($count) = mysql_fetch_row(mysql_query($sql));
// If you have more than one result, that's also a problem
if ($count == 1)
{
// You might want to set some session variables here, too.
header('Location:congrats.php');
}
else
{
echo "Invalid username and password combination";
}
Of course, you really shouldn't be using mysql_ functions either, but one thing at a time.