-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.php
66 lines (45 loc) · 1.46 KB
/
main.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
57
58
59
60
61
62
63
64
65
66
<?php
$showAlert = false;
$showError = false;
$exists=false;
if($_SERVER["REQUEST_METHOD"] == "POST") {
include 'dbcon.php';
$username = $_POST["username"];
$email = $_POST["email"];
$password = $_POST["password"];
$cpassword = $_POST["cpassword"];
$sql = "Select * from users where username='$username'";
$result = mysqli_query($conn, $sql);
$num = mysqli_num_rows($result);
if($num == 0) {
if(($password == $cpassword) && $exists==false) {
$hash = password_hash($password,
PASSWORD_DEFAULT);
// Password Hashing is used here.
$sql = "INSERT INTO `bug`(`id`, `username`, `email`, `password`, `cpassword`, `date`) VALUES ('$username', '$email', '$hash', current_timestamp())";
$result = mysqli_query($conn, $sql);
if ($result) {
$showAlert = true;
}
}
else {
$showError = "Passwords do not match";
}
}// end if
if($num>0)
{
$exists="Username not available";
}
}//end if
// if($_SERVER["REQUEST_METHOD"] == "POST")
// {
// $err = "";
// $name = $_POST["name"];
// $email = $_POST["email"];
// $password = $_POST["password"];
// $cpassword = $_POST["cpassword"];
// $exists = true;
// if(($password == $cpassword) && $exists){
// }
// }
?>