forked from jvbkw8/Group2Final
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignupVerify.php
33 lines (33 loc) · 1.25 KB
/
signupVerify.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
<?php
$user_name = $_POST['username'];
$user_password = $_POST['userpassword'];
$user_password_confirm = $_POST['password_confirm'];
if(!$user_name or !$user_password or !$user_password_confirm){
header("Location: signup.php?error=Please fill in all fields");
exit();
}
if($user_password != $user_password_confirm){
header("Location: signup.php?error=Passwords must match");
exit();
}
include "connection.php";
$conn = new mysqli($servername, $username, $password);
$usernamecheck = "select * from db.user where BINARY username = '$user_name';";
//echo $usernamecheck;
$result = $conn->query($usernamecheck);
if($result->num_rows != 0){
header("Location: signup.php?error=Username already exists");
exit();
}
$hashedPassword = password_hash($user_password, PASSWORD_DEFAULT);
$sql = "INSERT into db.user (username, hashedpassword, activeuserflag, isadmin) values ('$user_name', '$hashedPassword', 1, 0);";
//echo $sql;exit();
$conn->query($sql);
if($conn->affected_rows != 1){
header("Location: signup.php?error=Information not stored");
exit();
}
session_start();
$_SESSION[NAME] = $user_name;
header("Location: index.php");
?>