-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.php
128 lines (119 loc) · 4.47 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
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
119
120
121
122
123
124
125
126
127
128
<?php
session_start();
if (isset($_SESSION['loggedIn'])) {
header("location:./index.php");
exit();
}
$exist = false;
$didMatch = false;
$empty = false;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
include 'partials/dbconnect.php';
$name = $_POST["name"];
$useremail = $_POST["useremail"];
$usergender = $_POST["usergender"];
$username = $_POST["username"];
$password = $_POST["password"];
$repassword = $_POST["repassword"];
$userNameCheck = "SELECT * from `userdetails` WHERE `username` = '$username'";
$resultOfUserNameCheck = mysqli_query($con, $userNameCheck);
$numOfUserName = mysqli_num_rows($resultOfUserNameCheck);
if ($numOfUserName > 0) {
$exist = true;
} else {
if ($name == "" || $useremail == "" || $username == "" || $password == "") {
$empty = true;
} else if ($password != $repassword) {
$didMatch = true;
} else if (($password != "") && ($password == $repassword) && ($exist == false)) {
$passwordHash = password_hash($password, PASSWORD_DEFAULT);
$sql = "INSERT INTO `userdetails` (`name`, `useremail`, `usergender`, `userposition`, `phone_no`, `username`, `password`,`securitycode`, `createdtime`) VALUES ('$name', '$useremail', '$usergender', 'Bloggram User', NULL, '$username', '$passwordHash', NULL, current_timestamp())";
$result1 = mysqli_query($con, $sql);
$serializedArray = serialize(array());
$sql = "INSERT INTO `userfollowfollowing` (`username`, `follow`, `following`) VALUES ('$username', '$serializedArray', '$serializedArray')";
$result2 = mysqli_query($con, $sql);
if ($result1 && $result2) {
header("location:./login.php");
}
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>SignUp</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<link rel="stylesheet" href="css/utils.css" />
<link rel="stylesheet" href="css/signup-login.css" />
</head>
<body>
<section class="container d-flex">
<div class="welcome-card">
<img src="./img/logo.png" alt="" />
</div>
<div class="form-card cardup">
<?php
if ($empty) {
echo
"<div class='alert alert-danger' role='alert'>
<strong>Empty</strong> Fields.
</div>";
}
?>
<?php
if ($exist) {
echo
"<div class='alert alert-danger' role='alert'>
<strong>Username</strong> Already Taken.
</div>";
}
?>
<?php
if ($didMatch) {
echo
"<div class='alert alert-danger' role='alert'>
<strong>Passwords</strong> Didn't Match.
</div>";
}
?>
<form method="post">
<div class="formcontent">
<label>Name</label>
<input type="text" name="name" placeholder="ENTER YOUR NAME" />
</div>
<div class="formcontent">
<label>Email</label>
<input type="email" name="useremail" placeholder="ENTER YOUR EMAIL" />
</div>
<div class="formcontent">
<label>Gender</label>
<span><input type="radio" name="usergender" value="Male" checked />Male</span>
<span><input type="radio" name="usergender" value="Female" />Female</span>
</div>
<div class="formcontent">
<label>Username</label>
<input type="text" name="username" placeholder="ENTER YOUR USERNAME" />
</div>
<div class="formcontent">
<label>Password</label>
<input type="password" name="password" placeholder="ENTER YOUR PASSWORD" />
</div>
<div class="formcontent">
<label>Repassword</label>
<input type="password" name="repassword" placeholder="ENTER YOUR PASSWORD AGAIN" />
</div>
<div class="formcontent formcontent-btn">
<button class="btn" type="submit" name="submit">Submit</button>
<span><a href="login.php">Redirect to Login</a></span>
</div>
</form>
</div>
</section>
<!-- JavaScript Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
</body>
</html>