when I hit login it keeps saying invalid login information. I want it to go to profile.php
I used header('location:profile.php') I wonder whats wrong? may you guys take a look please, and let me know if I'm missing something or had typos. thanks!
//database information
$host = "localhost";
$user = "root";
$pass = "";
$db = "test";
//connect to database
mysql_connect($host, $user, $pass);
mysql_select_db($db);
//select table
$sql = "SELECT * FROM users WHERE username='".$username."' AND password='".$password."' LIMIT 1";
$res = mysql_query($sql);
?>
Admin Login
NJROTC ADMINS
You cannot be on this page if you weren't given the login information!
Answer
Here is your code:
echo "Invalid log in information.";
exit();
header ('location:profile.php');
First when you execute an echo the server sends headers to the browser, so you can’t have that before a header call. But past any of that you have an exit(); before the header ('location:profile.php'); call. So that will never execute it. Just do this instead:
// echo "Invalid log in information.";
// exit();
header ('location:profile.php');
Commenting out the echo and exit just in case there is a valid reason for you to have those there. Perhaps for debugging? But if this is in production, those are not needed.
No comments:
Post a Comment