I made website login with php and html. Code:
<?php
session_start();
$user="root";
$host="localhost";
$password="";
$database="mb_dusnionys_login";
$usertable="nariai";
mysql_connect ($host, $user,$password) or die ("negalima");
mysql_select_db ($database)or die (mysql_error());
$myusername=$_POST['username'];
$mypassword=$_POST['password'];
$sql="SELECT * FROM {$usertable} WHERE username='{$myusername}' AND password='{$mypassword}'";
$result = mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
$_SESSION ["username"]=$myusername;
$_SESSION ["password"]=$mypassword;
$_SESSION ["userrecord"]=mysql_fetch_assoc($result);
header ("location: /nariu_turinys/index.html");
}
else {
echo "Netinkamas vartotojo vardas arba slaptažodis. Grįžkite atgal ir bandykite iš naujo";
}
The conseption of my website: There is main index file with button and login form.Button redirects without login to other index file and login form redirects to third index file with requirement of username and pasw. In this directory are main parts of my website. Everything is ok when I use login form for log in website but if when I'm loged in and copy url to some part of page and paste in other browser or other tab I can reach this part without login. Question is that How to make these parts not available without login?