-
Notifications
You must be signed in to change notification settings - Fork 1
/
login.php
34 lines (34 loc) · 1.27 KB
/
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
30
31
32
33
34
<?php
$x = $_POST["emailid"];
$y = $_POST["pwd"];
$conn = mysqli_connect("localhost", "root", "sankeeth72", "test");
if (!$conn) {
die("Connection failed due to " . mysqli_connect_error());
}
$sql1 = "select * from test.account where emailid='$x' ";
$result = mysqli_query($conn, $sql1);
$a = mysqli_fetch_array($result);
if ($x == "admin" && $y == "admin") {
if (isset($_POST["remember"])) {
setcookie("emailid", $x, time() + 60 * 60, "/");
setcookie("pwd", $y, time() + 60 * 60, "/");
}
session_start();
$_SESSION["username"] = $x;
$_SESSION["pwd"] = $y;
header("Location:admin.php");
} else if ($a["password"] == $y) {
if (isset($_POST["remember"])) {
setcookie("emailid", $x, time() + 60 * 60, "/");
setcookie("pwd", $y, time() + 60 * 60, "/");
}
session_start();
$_SESSION["emailid"] = $x;
$_SESSION["username"] = $a["username"];
$_SESSION["pwd"] = $y;
header("Location:user.php");
} else {
echo "<p style='text-align:center;color:red;font-size:14px;font-weight:bold'>Wrong Passowrd or Username<br>Please TRy Again</p>";
include 'login1.php';
}
mysqli_close($conn);