-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.php
85 lines (72 loc) · 2.43 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
<?php
include 'config.php';
error_reporting(0);
session_start();
if (isset($_SESSION['username'])) {
header("Location: logindone.php");
}
if (isset($_POST['submit'])) {
$username = $_POST['username'];
$email = $_POST['email'];
$password = md5($_POST['password']);
$cpassword = md5($_POST['cpassword']);
if ($password == $cpassword) {
$sql = "SELECT * FROM users WHERE email='$email'";
$result = mysqli_query($conn, $sql);
if (!$result->num_rows > 0) {
$sql = "INSERT INTO users (username, email, password)
VALUES ('$username', '$email', '$password')"; // Submits the data twice for no reason, bugfix required! - Eniel
$result = mysqli_query($conn, $sql);
if ($result) {
$result = mysqli_query($conn, $sql);
header("Location: successsignup.php");
$username = "";
$email = "";
$_POST['password'] = "";
$_POST['cpassword'] = "";
} else {
echo "<script>alert('Whoops! Something Went Wrong.')</script>";
}
} else {
echo "<script>alert('Whoops! Email Already Exists.')</script>";
}
} else {
echo "<script>alert('Password Does Not Match Confirmation Password.')</script>";
}
}
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>TimeKeeper - Signup</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<a href="index.php"><img class="center" src="img/Untitled-1 copy.png" width="150px" alt="img1"></a>
<div class="login-box">
<form action="" method="POST">
<h1>Sign Up to TimeKeeper</h1>
<div class="textbox">
<i class="fas fa-user"></i>
<input type="text" name="username" placeholder="Username" value="<?php echo $username; ?>" required>
</div>
<div class="textbox">
<i class="fas fa-envelope-square"></i>
<input type="text" name="email" placeholder="Email" value="<?php echo $email; ?>" required>
</div>
<div class="textbox">
<i class="fas fa-lock"></i>
<input type="password" name="password" placeholder="Password" value="<?php echo $password; ?>" required>
</div>
<div class="textbox">
<i class="fas fa-lock"></i>
<input type="password" name="cpassword" placeholder="Confirm your Password" value="<?php echo $cpassword; ?>" required>
</div>
<div>
<button name="submit" class="btnm">SignUp</button>
</div>
</div>
</form>
</body>
</html>