-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.php
56 lines (48 loc) · 1.27 KB
/
signup.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
55
56
<?php
$username = $_POST["username"];
$pass = $_POST["password"];
$email = $_POST["email"];
$pn = $_POST["phonenumber"];
$conn = new mysqli("localhost","root","","rural");
if($conn->connect_error)
{
echo "error";
}
$sql1 = "SELECT `username`,`email`,`phonenumber` FROM `signup`;";
$table = mysqli_query($conn,$sql1);
$n = mysqli_num_rows($table);
while($n!=0)
{
$row = mysqli_fetch_assoc($table);
if($row["username"] == $username)
{
include("signup.html");
echo "<script>alert('USERNAME ALREADY EXISTS')</script>";
die();
}
if($row["email"] == $email)
{
include("signup.html");
echo "<script>alert('EMAIL ALREADY EXISTS')</script>";
die();
}
if($row["phonenumber"] == $pn)
{
include("signup.html");
echo "<script>alert('PHONE NUMBER ALREADY EXISTS')</script>";
die();
}
$n-=1;
}
$pass=password_hash($pass,PASSWORD_DEFAULT);
$sql2 = "INSERT INTO `signup` (`username`,`password`,`email`,`phonenumber`) VALUES ('$username','$pass','$email','$pn');";
if(mysqli_query($conn,$sql2))
{
echo "<script>location.href='login.html'</script>";
}
else
{
echo "error";
}
mysqli_close($conn);
?>