Docsity

PHP Session Management and User Authentication in MySQL Database, Study Guides, Projects, Research of Software Development

Toggle sidebar
bg1
<!doctype html>
<?php
session_start();
$servername="localhost";
$user="root";
$pass= "";
$database= "movies";
$message="";
$imessage="";
$con=mysqli_connect($servername,$user,$pass) or
die("not connected");
mysqli_select_db($con,$database)or
die("could not select database");
if (isset($_POST['login'])) {
$username= mysqli_real_escape_string($con,$_POST['username']);
$password= mysqli_real_escape_string($con,$_POST['password']);
$password=sha1($password);
$_SESSION['Nish18']=$username;
//checking from database;
$result=mysqli_query($con,"SELECT * FROM users WHERE email OR username=
'$username' AND password='$password' ");
if ($result->num_rows>0) {
$imessage=" &#10003 Login sucessful";
sleep(1);
header("location:home.php");
}
else{
$message="Username or password is incorrect" ;
}
}
?>

Partial preview of the text

Download PHP Session Management and User Authentication in MySQL Database and more Study Guides, Projects, Research Software Development in PDF only on Docsity!

num_rows>0) { $imessage=" &##10003 Login sucessful"; sleep(1); header("location:home.php"); t else{ $message="Username or password is incorrect" ;