index.php: if(mysql_num_rows($result)) { session_start(); $_SESSION['username'] = htmlspecialchars($username); // htmlspecialchars() sanitises XSS //header('location: dash.php'); echo $_SESSION['username']; } else { $error = "Invalid Username or Password"; } dash.php: