After submiting username and password in connect.php, user reaches contentselect.php .But if a user enters url like localhost/users/contentselect.php he is still able to see the contentselect.php page,which he should not see because he has not entered username and password in connect.php
//connect.php
<?php
Include ('mysql.php');
session_start();
if (isset($_POST['name'], $_POST['password']))
{
$name = $_POST['name'];
$password = $_POST['password'];
$password = md5($password);
$result = mysql_query("SELECT name,password FROM project WHERE name='" . $name . "' AND password='" . $password . "'");
if (mysql_num_rows($result) > 0)
{
$_SESSION['logged_in'] = true;
$_SESSION["name"] = $name;
header('Location:contentselect.php');
exit();
}
else
{
echo "wrong password or username";
}
}
?>
//this is contentselect.php
<?php
session_start();
echo "Hello ".$_SESSION["name"]."!";
?>