When I am submitting the form then I am landing on login.php and getting so many errors.
I have put errors on following link: https://docs.google.com/document/d/1AqwZ71iAQgZGMU-W0Go6czbpgGenF_f7ucgmEFw0AHo/edit
I am newbie and struggling for last 5 hours with above code. I have following pages in my login logout system:
db.php
<?php
$conn=new mysqli('localhost','root','','people');
?>
index.php
<?php
session_start();
?>
<html>
<head></head>
<body>
<form method="post" name="login" action="login.php">
<label for="name" class="labelname"> Username </label>
<input type="text" name="username" id="userid" required="required" /><br />
<label for="name" class="labelname"> Password </label>
<input type="password" name="password" id="passid" required="required" /><br />
<input type="submit" name="submit" id="submit" value="Login" />
</form>
</body>
</html>
login.php
<?php
include('db.php');
session_start();
{
$user=mysqli_real_escape_string($_POST['username']);
$pass=mysqli_real_escape_string($_POST['password']);
$fetch=mysqli_query("SELECT id FROM `user` WHERE
username='$user' and password='$pass'");
$count=mysqli_num_rows($fetch);
if($count!="")
{
session_register("sessionusername");
$_SESSION['login_username']=$user;
header("Location:profile.php");
}
else
{
header('Location:index.php');
}}
?>
logout.php
<?php
session_start();
if(session_destroy())
{
header("Location: index.php");
}
?>
session.php
<?php
include('db.php');
session_start();
$check=$_SESSION['login_username'];
$session=mysqli_query("SELECT username FROM `user` WHERE username='$check' ");
$row=mysqli_fetch_array($session);
$login_session=$row['username'];
if(!isset($login_session))
{
header("Location:index.php");
}
?>
profile.php
<?php
include('db.php');
session_start();
$check=$_SESSION['login_username'];
$session=mysqli_query("SELECT username FROM `user` WHERE username='$check' ");
$row=mysqli_fetch_array($session);
$login_session=$row['username'];
if(!isset($login_session))
{
header("Location:index.php");
}
?>