-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsignup.php
87 lines (85 loc) · 2.73 KB
/
signup.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
<?php
$host = 'localhost';
$user='root';
$password = 'root';
$db = 'project';
$conn = mysqli_connect($host,$user,$password,$db);
$conn_error = mysqli_connect_error();
$query="SELECT * FROM `users`";
$results = mysqli_query($conn, $query);
$Name=filter_input(INPUT_POST,'Name');
$Password=filter_input(INPUT_POST,'Password');
$ConfPassw=filter_input(INPUT_POST,'ConfPassw');
$free=true;
if (isset($Name)){
while ($row = mysqli_fetch_array($results)) {
if ($row['login']==$Name){
$free=false;
break;
}
}
if ($free && $Password==$ConfPassw){
$query="INSERT INTO `users` (`login`, `password`, `admin`) VALUES ('".$Name."', '".$Password."', '0');";
$results = mysqli_query($conn, $query);
setcookie("admin", "", time() - 100);
setcookie("user", $Name);
header("Location: index.html");
die();
}
}
if ($conn_error != null){
echo "There is some connection error:<p> $conn_error </p>";
}
?>
<html>
<head>
<meta charset="UTF-8">
<title>Movies</title>
<link rel="stylesheet" href="signin.css">
</head>
<body>
<div class = "header">
<div class = "header_section">
<div class = "headerlogo"><a href="index.html">Marvel Universe</a></div>
<div class = "headerButton"><a href = "characters.php">Characters</a></div>
<div class = "headerButton"><a href = "comics.php">Comics</a></div>
<div class = "headerButton"><a href = "#">Games</a></div>
<div class = "headerButton"><a href = "movies.php">Movies</a></div>
<div class = "headerButton"><a href = "signin.php">Sign in</a></div>
</div>
</div>
<?php
if (isset($Name)){
echo "<div id='errors'>";
if(!$free){
echo "<div class='error'>";
echo "This username " .$Name . " is already reserved!!!";
echo "</div>" ;
echo "<br>";
}
if($Password!=$ConfPassw){
echo "<div class='error'>";
echo "Password and Confirm password does not equal to each other";
echo "</div>";
echo "<br>";
}
echo "</div>";
}
mysqli_close($conn);
?>
<form action = "signup.php" method="post">
<div class="container">
<h1>Sign up</h1>
<hr>
<label for="username"><b>Username:</b></label>
<input type="text" name="Name" placeholder="Enter Username" required>
<label for="psw"><b>Password:</b></label>
<input type="password" name="Password" placeholder="Enter Password" required>
<label for="ConfPassw"><b>Confirm Password:</b></label>
<input type="password" name="ConfPassw" placeholder="Password one more time" required>
<hr>
<button type="submit" id="signin">Enter</button>
</div>
</form>
</body>
</html>