-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_login_con.php
51 lines (40 loc) · 1.04 KB
/
admin_login_con.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
<?php
$serverName = "localhost";
$user = "root";
$password = "";
$database = "student_management_system";
//start session
session_start();
//check user alrady loged in
if (isset($_SESSION['txtUserName'])) {
header('Location:admin_home.php');
}
//username password sent from form
if ($_SERVER["REQUEST_METHOD"] == "POST") {
//create connection
$con = mysqli_connect($serverName, $user, $password, $database);
//check connection
if (!$con) {
die("connection Failed!" . mysqli_connect_errno());
}
$sql = "SELECT * FROM admin_login_data WHERE adminUN='$_POST[txtUserName]' AND adminPW='$_POST[txtPassword]'";
$result = mysqli_query($con, $sql);
if (mysqli_num_rows($result) > 0) {
//output data
?>
<script language="javascript">
alert('Welcome Admin!'); //JS alert
location = 'admin_home.php';
</script>
<?php
} else {
?>
<script language="javascript">
alert('Wrong User Name or Password'); //JS alert
location = 'admin_login.php';
</script>
<?php
}
}
mysqli_close($con);
session_destroy();