-
Notifications
You must be signed in to change notification settings - Fork 1
/
studRegistration.php
118 lines (116 loc) · 3.83 KB
/
studRegistration.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
$username = filter_input(INPUT_POST, 'username');
$password = md5(filter_input(INPUT_POST, 'password'));
$confirmPassword = md5(filter_input(INPUT_POST, 'confirmPassword'));
$institute = filter_input(INPUT_POST, 'institute');
$entry = "unsuccess";
if($_SERVER["REQUEST_METHOD"] == "POST"){
if(!empty($username)){
if(!empty($password))
{
if($password != $confirmPassword){
echo '<script language="javascript">';
echo 'alert("Password and confirm password must be same")';
echo '</script>';
die();
}
else
{
$host = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbname = "lms";
$conn = new mysqli($host, $dbusername, $dbpassword, $dbname);
if(mysqli_connect_error())
{
die('Connect Error ('.mysqli_connect_error().')'.mysqli_connect_error());
}
else
{
$sql = "SELECT * FROM adminregistration WHERE institute = '$institute'";
$result = $conn->query($sql);
if($result->num_rows > 0)
{
$row = $result->fetch_assoc();
$adminname = $row["username"];
$entry = "success";
echo "<center><p style='color:#ffffff;'>Registration successfully</p></center>";
}
else
{
echo "Error: ". $sql ."<br>". $conn->error;
}
$conn->close();
}
}
}
else
{
echo '<script language="javascript">';
echo 'alert("Password is empty")';
echo '</script>';
}
}
else
{
echo '<script language="javascript">';
echo 'alert("Username is empty")';
echo '</script>';
die();
}
if($entry == "success")
{
$host = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbname = $adminname;
$conn1 = new mysqli($host, $dbusername, $dbpassword, $dbname);
if(mysqli_connect_error())
{
die('Connect Error ('.mysqli_connect_error().')'.mysqli_connect_error());
}
else
{
$sql1 = "INSERT INTO studentdetail (username, password) values('$username', '$password');";
if($conn1->query($sql1)){
echo "Data Successfully Inserted";
}
else
{
echo "Error: ". $sql1 ."<br>". $conn1->error;
}
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>
Library Managemenr System
</title>
<link rel="stylesheet" type="text/css" href="CSS/studRegisterStyle.css">
</head>
<body background="Images/home.jpg">
<center>
<div>
<img src="Images/home1.jpg" class = "topImage">
</div>
<br>
<div id = "bottomLayout">
<div id ="bottom-left"><a href = "adminRegister.php" id = "linkAdmin"><img src = "Images/studRegistration.png" height = "200" width = "200" id = "imageL"></a><br><p id ="bottomContentLeft"> Student Registration</p></div>
<div id ="bottom-right">
<form action="studRegistration.php" method = "post">
<table id = "formLayout" cellspacing="10">
<tr id = "rowLayout"><td id="rowHeading"> Username : </td><td><input type="text" name="username" id = "input" required></td></tr>
<tr id = "rowLayout"><td id="rowHeading"> Password : </td><td><input type="password" name="password" id = "input" required></td></tr>
<tr id = "rowLayout"><td id="rowHeading"> Confirm Password : </td><td><input type="password" name="confirmPassword" id = "input"></td></tr>
<tr id = "rowLayout"><td id="rowHeading"> Institute : </td><td><input type="text" name="institute" id = "input"></td></tr>
</table>
<br><center><input type="submit" value="Register" id="buttonFont"></center><br>
</form>
</div>
</div>
</center>
</body>
</html>