Im writing a login script. My db.php doesnt echo/print anything so why doesnt header("Location: index.php"); redirect upon successful login? the login info is correct. I know i need to sanitize the input but that is not a problem at the moment.
<?php
require('db.php');
$username = $_POST['un'];
$password = $_POST['pw'];
$qry="SELECT uid FROM users WHERE name='$username' AND pass='".md5($password)."'";
$result=mysql_query($qry);
if(mysql_num_rows($result) == 1){
session_regenerate_id();
$user = mysql_fetch_assoc($result);
$_SESSION['S_UID'] = $user['uid'];
session_write_close();
header("Location: index.php");
exit();
}else{
echo "<center><form action='index.php' name='login'>Login failed! Please try again with correct username and password.<br><input type='submit' name='failed' value='Return to Login'></form></center>";
exit();
}
?>