-
Notifications
You must be signed in to change notification settings - Fork 2
/
registrar.php
45 lines (35 loc) · 1.29 KB
/
registrar.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
<html>
<body>
<?php
include 'connection.php';
$userid=$_POST['userid'];
$phone=$_POST['phone'];
$sql = "SELECT * FROM login WHERE username='$userid'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
$message="user with the entered e-mail address already exists.";
echo"<script type='text/javascript'> { alert('$message');} window.location.replace('signup.html');</script>";
}
else {
$sql = "SELECT * FROM login";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) {
if(strcmp($phone,$row["mob"])==0)
{
$message="user with the entered mobile number already exists.";
echo "<script type='text/javascript'> { alert('$message');} window.location.replace('signup.html');</script>";
}
}
$sql="INSERT INTO login (name,username,mob,password,secques,answer) VALUES ('$_POST[name]','$_POST[userid]','$_POST[phone]','$_POST[pass]','$_POST[secques]','$_POST[answer]')";
if ($conn->query($sql) === TRUE) {
header("Location:home.php"); /* Redirect browser */
exit();}
else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
mysqli_close($conn);
}
?>
</body>
</html>