I'm making a php login that will redirect you to "admin.php" when you have logged in, this is my code so far, it worked when I echoed the rows with the username and password in, but when I added in a if and else statement it just gives me a blank screen with no error or anything. Here is my code:
NOTE: I have changed the mysql database details, but I have tested them and they all connect.
<?php
mysql_connect("mysqlserver", "myusername", "mypassword);
mysql_select_db("mydatebase");
?>
<html>
<head>
</head>
<body>
<?php
if(isset($_POST['submit'])){
$user = $_POST['user'];
$pass = $_POST['password'];
$result = mysql_query("SELECT * FROM user WHERE name='$user' AND pass='$pass'");
$num = mysql_num_rows($result);
if($num == 0) {
echo "Incorrect UserName or Password. Please try again."; session_start();
}else{
session_start();
$_SESSION['user'] = $user;
header("Location: admin.php");
}
?>
<form action='login.php' method='post'>
UserName: <input type='text' name='user' /><br />
Password: <input type='password' name='password' /><br />
<input type='submit' name='submit' value='Login' />
</form>
<?php
}
?>
</body>
</html>