Here is my code:
I have started the session at the top of the page index.php already
`
if(isset($_POST['btsubmit'])){
$username=$_POST['txtname'];
$password=$_POST['txtpass'];
$sql="SELECT * FROM tbuser WHERE AccountName='$username' AND Password='$password'";
$query=mysql_query($sql) or die(mysql_error());
if($username="" or $password=""){
echo"Your box is empty";
}else{
if($row = mysql_fetch_array($query)){
$_SESSION['AccountName']= $row['AccountName'];
header("Location: welcome.php");
exit();
}else{
echo "fail";
}
}
}
?>`
When I login success, it does not redirect to the page welcome.php, it stays at index.php the same. Any help would be appreciated. Thanks..
First off, Don’t use
mysql_*functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi – this article will help you decide which. If you choose PDO, here is a good tutorial.To build on my comment: