-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnew_user.php
85 lines (69 loc) · 2.96 KB
/
new_user.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
<?php
include("config.php");
if($_SERVER["REQUEST_METHOD"] == "POST") {
// username and password sent from form
$myusername = mysqli_real_escape_string($db,$_POST['username']);
$mypassword = mysqli_real_escape_string($db,$_POST['pwd1']);
$sql = "SELECT id FROM login WHERE username = '$myusername' and password = '$mypassword'";
$result = mysqli_query($db,$sql) or die( mysqli_error($db));
define("count" ,mysqli_num_rows($result));
echo count;
if(count>=1){
$error="Try other Name";
}
else{
$sql = "INSERT INTO `login` (`ID`, `username`, `password`) VALUES (NULL, '$myusername', '$mypassword')";
$result = mysqli_query($db,$sql) or die( mysqli_error($db));
// echo "$result";
// $count = mysqli_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($result == 1) {
echo "Successful";
// header("location: login.php");
}
else {
$error = "Unable to Create Account Contact Admin";
}
}
}
?>
<html>
<head>
<title>Create New Account</title>
<style type = "text/css">
body {
font-family:Arial, Helvetica, sans-serif;
font-size:14px;
}
label {
font-weight:bold;
width:100px;
font-size:14px;
}
.box {
border:#666666 solid 1px;
}
</style>
</head>
<body bgcolor = "#FFFFFF">
<div align = "center">
<div style = "width:400px; border: solid 1px #333333; margin-top: 25px;" align = "left">
<div style = "background-color:#333333; color:#FFFFFF; padding:3px; justify-content: space-between;"><b>Create New Account</b>
</div>
<div align="center" style = "margin:30px">
<table cellspacing="4" >
<form action = "" method = "post">
<tr align="left"><th>Username:</th><td> <input type="text" required pattern="\w+" name="username"></td>
<tr align="left"><th >Password:</th><td> <input type="password" name="pwd1" required pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}" onchange="form.pwd2.pattern = (this.value);"></td> <!--required pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}"-->
<tr align="left"><th>Confirm Password:</th><td> <input type="password" required name="pwd2"></td>
<tr><th colspan="2"><input type = "submit" value = " Submit "/>
</form>
</table>
<a href="/project/admin.php"> <button >Admin Login</button></a>
<a href="/project/login.php"> <button >Login</button></a>
<div style = "font-size:11px; color:#cc0000; margin-top:10px"><?php echo $error; ?></div>
</div>
</div>
</div>
</body>
</html>