query($sql); while($row = $ret->fetchArray() ){ print_r($row); $uname=$row["name"]; $pwd=$row['password']; } if ($pwd==$_POST["password"] && $uname==$_POST["uname"]){ $_SESSION["login"]=$uname; header('Location: main.php'); } else{ $_SESSION['errors'] = array("Your username or password was incorrect."); header("Location:index.php"); } ?>