0% found this document useful (0 votes)
7 views2 pages

Admin

This PHP document implements an admin login system for an online quiz application. It handles user authentication by checking the provided email and password against a database, and it manages user sessions accordingly. If the login is successful, the user is redirected to a dashboard; otherwise, an error message is displayed.

Uploaded by

rahulrathod20606
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Admin

This PHP document implements an admin login system for an online quiz application. It handles user authentication by checking the provided email and password against a database, and it manages user sessions accordingly. If the login is successful, the user is redirected to a dashboard; otherwise, an error message is displayed.

Uploaded by

rahulrathod20606
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1 <?

php
2 include_once 'database.php';
3 session_start();
4 if(isset($_SESSION["email"]))
5 {
6 session_destroy();
7 }
8
9 $ref=@$_GET['q'];
10 if(isset($_POST['submit']))
11 {
12 $email = $_POST['email'];
13 $password = $_POST['password'];
14
15 $email = stripslashes($email);
16 $email = addslashes($email);
17 $password = stripslashes($password);
18 $password = addslashes($password);
19
20 $email = mysqli_real_escape_string($con,$email);
21 $password = mysqli_real_escape_string($con,$password);
22
23 $result = mysqli_query($con,"SELECT email FROM admin WHERE email = '$email' and
password = '$password'") or die('Error');
24 $count=mysqli_num_rows($result);
25 if($count==1)
26 {
27 session_start();
28 if(isset($_SESSION['email']))
29 {
30 session_unset();
31 }
32 $_SESSION["name"] = 'Admin';
33 $_SESSION["key"] ='admin';
34 $_SESSION["email"] = $email;
35 header("location:dashboard.php?q=0");
36 }
37 else
38 {
39 echo "<center><h3><script>alert('Sorry.. Wrong Username (or)
Password');</script></h3></center>";
40 header("refresh:0;url=admin.php");
41 }
42 }
43 ?>
44 <!DOCTYPE html>
45 <html>
46 <head>
47 <meta charset="UTF-8">
48 <meta name="viewport" content="width=device-width, initial-scale=1.0">
49 <meta http-equiv="X-UA-Compatible" content="ie=edge">
50 <title>Admin Login | Online Quiz System</title>
51 <link rel="stylesheet" href="scripts/bootstrap/bootstrap.min.css">
52 <link rel="stylesheet" href="scripts/ionicons/css/ionicons.min.css">
53 <link rel="stylesheet" href="css/form.css">
54 <style type="text/css">
55 body{
56 width: 100%;
57 background: url(image/book.png) ;
58 background-position: center center;
59 background-repeat: no-repeat;
60 background-attachment: fixed;
61 background-size: cover;
62 }
63 </style>
64 </head>
65
66 <body>
67 <section class="login first grey">
68 <div class="container">
69 <div class="box-wrapper">
70 <div class="box box-border">
71 <div class="box-body">
72 <center> <h5 style="font-family: Noto Sans;">Login to </h5><h4
style="font-family: Noto Sans;">Admin Page</h4></center><br>
73 <form method="post" action="admin.php" enctype=
"multipart/form-data">
74 <div class="form-group">
75 <label>Enter Your Email Id:</label>
76 <input type="email" name="email" class="form-control"
>
77 </div>
78 <div class="form-group">
79 <label class="fw">Enter Your Password:
80 <a href="javascript:void(0)" class="pull-right">
Forgot Password?</a>
81 </label>
82 <input type="password" name="password" class=
"form-control">
83 </div>
84 <div class="form-group text-right">
85 <button class="btn btn-primary btn-block" name=
"submit">Login</button>
86 </div>
87
88 </form>
89 </div>
90 </div>
91 </div>
92 </div>
93 </section>
94
95 <script src="js/jquery.js"></script>
96 <script src="scripts/bootstrap/bootstrap.min.js"></script>
97 </body>
98 </html>

You might also like