-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignup.php
More file actions
84 lines (79 loc) · 1.94 KB
/
signup.php
File metadata and controls
84 lines (79 loc) · 1.94 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
$server_name="localhost";
$user="root";
$pass="";
$db="restaurent";
$conn=mysqli_connect($server_name,$user,$pass,$db);
if(!$conn){
die("unable to connect:".$conn->connect_error);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Sign Up</title>
<style type="text/css">
form{
border: 5px solid black;
width:300px;
padding: 2px;
}
</style>
</head>
<body>
<?php
$msg="";
if(isset($_POST['submit'])){
$name=$_POST['fname'];
$email=$_POST['email'];
$pas=$_POST['pass'];
$sql="SELECT EmailId from user";
$result=mysqli_query($conn,$sql);
$a=mysqli_num_rows($result);
$c=$a;
if($a>0){
while($row=mysqli_fetch_assoc($result)){
//echo $a." ".$c;
if($row['EmailId']==$email){
$msg="Email is already taken";
break;
}
else if(($c==1) and ($row['EmailId']!=$email) ){
$s = "INSERT INTO user(FullName, EmailId, Password) VALUES('$name','$email','$pas')";
if(mysqli_query($conn,$s)){
echo "<script>alert('Successfully Registered')</script>";
}
else{
echo "Error: " . $s . "<br>" . mysqli_error($conn);
}
}
$a--;
$c--;
}
}
else{
$s = "INSERT INTO user(FullName, EmailId, Password)VALUES('$name','$email','$pas')";
if(mysqli_query($conn,$s)){
echo "<script>alert('Successfully Registered')</script>";
}
else{
echo "Error: " . $s . "<br>" . mysqli_error($conn);
}
}
}
?>
<center>
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);
?>" method="post">
<label>Full Name</label><br/>
<input type="text" name="fname" required="required"><br/><br/>
<label>Email Id</label><br/>
<input type="email" name="email" required="required"><br/>
<p style="background: red;"><?php echo $msg;?></p>
<label>Password</label><br/>
<input type="password" name="pass" required="required"><br/><br/>
<button type="submit" name="submit">submit</button>
</form>
</center>
</body>
</html>