-
Notifications
You must be signed in to change notification settings - Fork 0
/
register.php
38 lines (31 loc) · 1.2 KB
/
register.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
<?php
session_start();
$mysqli = new mysqli("localhost", "root", "", "tajhotel");
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($_POST['password'] == $_POST['confirmpassword']) {
$username = $mysqli->real_escape_string($_POST['username']);
$email = $mysqli->real_escape_string($_POST['email']);
$password = $_POST['password'];
$checkuser = $mysqli->query("SELECT * FROM register WHERE username='$username'");
$rows = mysqli_num_rows($checkuser);
if($rows == 1){
echo "<script type=\"text/javascript\">window.alert('User already present.');
window.location.href = '/hotel/homepage.php';</script>";
exit;
}
$sql = "INSERT INTO register (username, email, password) "
. "VALUES ('$username', '$email', '$password')";
if ($mysqli->query($sql) === true){
echo "<script type=\"text/javascript\">window.alert('Succesfully Signed up.');
window.location.href = '/hotel/homepage.php';</script>";
exit;
}
$mysqli->close();
}
else {
echo "<script type=\"text/javascript\">window.alert('Both Passwords did not match');
window.location.href = '/hotel/homepage.php';</script>";
exit;
}
}
?>