-
Notifications
You must be signed in to change notification settings - Fork 0
/
login2.php
43 lines (35 loc) · 1.2 KB
/
login2.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
35
36
37
38
39
40
41
42
<?php
// mysqli_connect() function opens a new connection to the MySQL server.
include ('includes/connec.inc.php');
session_start(); // Starting Session
$error = ''; // Variable To Store Error Message
if (isset($_POST['submit'])) {
if (empty($_POST['email']) || empty($_POST['password'])) {
$error = "email or Password is invalid";
}
else
{
// Define $email and $password
$email = mysqli_real_escape_string($conn, $_POST['email']);
$password_1 = mysqli_real_escape_string($conn,$_POST['password']);
$password = md5($password_1);
// SQL query to fetch information of registerd users and finds user match.
$query = "SELECT email, password from eaouser where email=? AND password=? LIMIT 1";
// To protect MySQL injection for Security purpose
$stmt = $conn->prepare($query);
$stmt->bind_param("ss", $email, $password);
$stmt->execute();
$stmt->bind_result($email, $password);
$stmt->store_result();
if($stmt->fetch()) //fetching the contents of the row
{
$_SESSION['email'] = $email; // Initializing Session
header("location: eaodashboard.php"); // Redirecting To Profile Page
}
else {
$error = "email or Password is invalid";
}
mysqli_close($conn); // Closing Connection
}
}
?>