-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhandlesignup.php
39 lines (32 loc) · 1.14 KB
/
handlesignup.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
<?php
$showEroor="false";
if($_SERVER["REQUEST_METHOD"]=="POST"){
include 'dbconnect.php';
$user_email=$_POST['signupEmail'];
$pass=$_POST['signupPassword'];
$cpass=$_POST['cPassword'];
//check weather this gmail exist
$existSql="SELECT * FROM `users` WHERE user_email='$user_email' ";
$result=mysqli_query($conn,$existSql);
$numRows=mysqli_num_rows($result);
if($numRows>0){
$showEroor="Email already in use";
}
else{
if($pass==$cpass){
$hash=password_hash($pass,PASSWORD_DEFAULT);
$sql="INSERT INTO `users` ( `user_email`, `user_pass`, `timestamp`) VALUES ( '$user_email', '$pass', current_timestamp());";
$result=mysqli_query($conn,$sql);
if($result){
$showAlert=true;
header("Location: /MyForum/index.php?signupsuccess=true");
exit();
}
}
else{
$showEroor="Password do not match";
}
}
header("Location: /MyForum/index.php?signupsuccess=false&error=$showEroor");
}
?>