-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignup.php
More file actions
47 lines (38 loc) · 1.52 KB
/
signup.php
File metadata and controls
47 lines (38 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
<?php
include "partials/_sessionHead.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$studentEmail = $_POST['studentEmail'];
$studentFirstName = $_POST['studentFirstName'];
$studentLastName = $_POST['studentLastName'];
$studentPassword = $_POST['studentPassword'];
$studentCPassword = $_POST['studentCPassword'];
$studentAdminPassword = $studentPassword;
// Check whether this username exists
$existSql = "SELECT * FROM `users` WHERE studentEmail = '$studentEmail'";
$result = mysqli_query($con, $existSql);
$numExistRows = mysqli_num_rows($result);
if($numExistRows > 0){
echo "This Email ID already exists";
header('location: index.php?signup=exists');
} else{
if($studentPassword == $studentCPassword){
$hash = password_hash($studentPassword, PASSWORD_DEFAULT);
$sql = "INSERT INTO `users` (`studentEmail`, `studentFirstName`, `studentLastName`, `studentPassword`, `studentOccupation`, `studentDP`, `studentAdminPassword`) VALUES ('$studentEmail', '$studentFirstName', '$studentLastName', '$hash', '', '', '$studentAdminPassword')";
$result = mysqli_query($con, $sql);
if($result){
echo "Student Added";
header('location: index.php?signup=success');
}
}
else{
echo "Passwords do not match";
header('location: index.php?signup=unmatch');
}
}
}
if ($result) {
echo "Yes";
} else {
echo "No";
}
?>