-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.php
81 lines (80 loc) · 2.19 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
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
<?php
$aleart=false;
$error=false;
include "conn.php" ;
if($_SERVER["REQUEST_METHOD"] == "POST"){
$username=$_POST['username'];
$email=$_POST["email"];
$pass=$_POST["pass"];
$passHash=password_hash($pass, PASSWORD_DEFAULT);
$cpass=$_POST["cpass"];
$sqlexists="SELECT * FROM `loginid` WHERE email='$email' " ;
$result = mysqli_query($conn,$sqlexists);
$numexists = mysqli_num_rows($result);
if($numexists>0){
$error="Account already registered.";
}else{
if($pass==$cpass){
$sql="INSERT INTO `loginid` (`username`,`email`, `pass`, `time`) VALUES ('$username','$email', '$passHash', current_timestamp());" ;
$result=mysqli_query($conn,$sql);
if($result){
$aleart=true;
}
}
else{
$error="password do not match . please check your password";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include "link.php" ;
include "conn.php" ; ?>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>sign up</title>
</head>
<body>
<?php require "navbar.php"; ?>
<?php
if($aleart){
echo '<div class="Salert">
<strong>Success! </strong>Your accound is successfully created and now you can login. <a href="login.php">Login now.</a>
</div>';
}
?>
<?php
if($error){
echo '<div class="Dalert">
<strong>Failed! </strong> '.$error.'
</div>';
}
?>
<div class="form">
<form class="form-box" action="signup.php" method="post">
<h1>sign Up</h1>
<div class="textbox">
<label>Username</label>
<input type="text" maxlength="30" name="username" required>
</div>
<div class="textbox">
<label>Email</label>
<input type="email" maxlength="30" name="email" required>
</div>
<div class="textbox">
<label>Password</label>
<input type="password" name="pass" required>
</div>
<div class="textbox">
<label>Confirm Password</label>
<input type="password" name="cpass" required>
</div>
<button type="submit" class="btn" value="submit" name="submit">Signup</button>
<p>Have an account ?</p>
<a href="login.php">Sign in</a>
</form>
</div>
</body>
</html>