-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_admin_script.php
More file actions
56 lines (46 loc) · 1.52 KB
/
add_admin_script.php
File metadata and controls
56 lines (46 loc) · 1.52 KB
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
<?php
if(isset($_POST['submit']))
{
$username=$_POST['username'];
$password=$_POST['password'];
$link = mysqli_connect("localhost:3307", "root", "", "student_database");
if($link===false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$pwd_hash= password_hash($password,PASSWORD_DEFAULT);
$sql="insert into admin(username,password) values('$username','$pwd_hash')";
if(mysqli_query($link,$sql)){
echo "admin added successfully.";
}else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
mysqli_close($link);
}
?>
<html>
<head>
<meta charset="utf-8">
<title>add user information...</title>
</head>
<h1 align="center">Create New User Admin</h1><br>
<body>
<form method="post" action="add_admin_script.php">
<table align="center" style="padding:5px; " class="table table-bordered table-striped">
<tr>
<th>Enter Username</th>
<td><input type="text" name="username" placeholder="Username" required /></td>
</tr>
<tr>
<th>Enter Password</th>
<td> <input type="password" name="password" placeholder="password" required /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" /></td>
</tr>
</table>
</form>
<center>
<a href="login.php"><button class="btn btn-primary">Back to Login</button></a>
</center>
</body>
</html>