forked from RajeshPerro/CodersTrust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
68 lines (65 loc) · 1.78 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
* Created by PhpStorm.
* User: rajesh
* Date: 11/2/15
* Time: 9:48 AM
*/
session_start();
include('pdo_connection.php');
include('database_config.php');
$db_user =$database_user;
$db_pass =$databse_pass;
$db_name=$database_name;
$dbcon=$connection_object->connection('localhost',$db_user,$db_pass,$db_name);
if(isset($_POST['login']))
{
$Email=$_POST['email'];
$Pass=$_POST['password'];
$sql="SELECT * FROM employee WHERE email='$Email' AND password='$Pass'";
$data = $dbcon->query($sql);
$row = $data->fetch(PDO::FETCH_ASSOC);
trim($dbuser = $row['email']);
trim($dbpass = $row['password']);
if ($dbpass != "" && $dbuser != "")
{
session_start();
$_SESSION['user'] = $dbuser;
echo("<script>location.href='user_data.php'</script>");
}
else {
$string = ' Sorry! Try again.\n Username or Password is Wrong.';
echo "<script>alert(\"$string\")</script>";
echo("<script>location.href='login.php'</script>");
}
}
?>
<html>
<head>
<title>User | Login</title>
</head>
<body>
<center>
<table>
<tr>
<th></th>
<th style="font-size: larger;">User Login</th>
</tr>
<form action="" method="post">
<tr>
<td>E-mail: </td>
<td><input type="email" name="email" size="20"></td>
</tr>
<tr>
<td>Password: </td>
<td><input type="password" name="password" size="20"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="login" value="Login" size="20" style="background-color: green; color: white;"> <a href="index.php"><input type="button" value="Cancel" size="20" style="background-color: darkred; color: white;"></a></td>
</tr>
</form>
</table>
</center>
</body>
</html>