-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.inc.php
49 lines (37 loc) · 1.36 KB
/
signup.inc.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
<?php
if(isset($_POST['signup-submit'])){
require 'db.inc.php';
$username = $_POST['uname'];
$name = $_POST['name'];
$email = $_POST['mail'];
$phone = $_POST['phone'];
$password = $_POST['pass'];
$rep_pass = $_POST['rpass'];
if($password!=$rep_pass){
header("Location: signup.php?error=Incorrect Password&uname=".$username."&name=".$name."&mail=".
$email."&phone=".$phone);
exit();
}
$check = "SELECT * FROM USERS WHERE Username='".$username."';";
$result = mysqli_query($conn, $check);
if(mysqli_num_rows($result)>=1){
header("Location: signup.php?error=User Already Exists&uname=".$name."&mail=".
$email."&phone=".$phone);
exit();
}
else{
$hashed_pwd = password_hash($password, PASSWORD_DEFAULT);
$sql = "INSERT INTO Users (username,password,name,phone,email) VALUES ('$username','$hashed_pwd','$name',
'$phone','$email');";
if(!mysqli_query($conn, $sql)){
die('Error: '.mysqli_error());
}
header("Location: signup.php?signup=Signup Successful");
exit();
mysqli_close($conn);
}
}
else{
header("Location: signup.php");
}
?>