-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
29 lines (29 loc) · 850 Bytes
/
login.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
include('admin/config.php');
session_start();
if(!isset($_SESSION['cart'])) $_SESSION['cart'] = array();
if (isset($_POST['submit']))
{
$username = mysqli_real_escape_string($link, $_POST['username']);
$password = mysqli_real_escape_string($link, $_POST['password']);
$sql = "SELECT usr,pswd FROM users WHERE usr = '".$username."' and pswd ='".$password."'";
$result = mysqli_query($link, $sql);
if (!$result)
{
$error = 'Error' . mysqli_error($link);
include 'error.html.php';
exit();
}
if(mysqli_num_rows($result)>0){
$_SESSION['login'] = $username;
header("Location:main.php");
}
else
echo "Invalid Login";
}
if (isset($_REQUEST['logout']))
{
session_destroy();
header("Location:index.php");
}
?>