-
Notifications
You must be signed in to change notification settings - Fork 1
/
registration.php
54 lines (37 loc) · 1.67 KB
/
registration.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
<?php
include 'db_connect.php'; //connection
if(isset($_POST['submit'])){
$username=mysqli_real_escape_string($con,$_POST['username']); //store the username in the variable 1
$email=mysqli_real_escape_string($con,$_POST['email']);
$mobile=mysqli_real_escape_string($con,$_POST['mobile']);
$password=mysqli_real_escape_string($con,$_POST['password']);
$cpassword=mysqli_real_escape_string($con,$_POST['cpassword']);
$pass=password_hash($password,PASSWORD_BCRYPT); //Used for Encrypt the Password
$cpass=password_hash($cpassword,PASSWORD_BCRYPT);
$emailquery="select * from users where email='$email'";
$query=mysqli_query($con,$emailquery);
$emailcount=mysqli_num_rows($query);
if($emailcount>0){
echo "<script>alert('Email already Exists')</script>";
echo "<script>location.href='index.php'</script>";
}
else{
if($password === $cpassword){
$insertquery="insert into users(username,email,mobileNumber,password,currentpassword) values('$username','$email','$mobile','$pass','$cpass')";
$iquery=mysqli_query($con,$insertquery);
if ($iquery) {
echo "<script>alert('Successfully created an account in FashiKnow')</script>";
echo "<script>location.href='home.php'</script>";
}
else{
echo "<script>alert('There was an Error while creating account')</script>";
echo "<script>location.href='index.php'</script>";
}
}
else{
echo "<script>alert('Passwords are not maching')</script>";
echo "<script>location.href='index.php'</script>";
}
}
}
?>