-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistration.php
136 lines (120 loc) · 4.26 KB
/
registration.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
include 'connection.php';
if(isset($_POST['register'])){
$name = $_POST['name'];
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$cnfpassword=$_POST['confirmpassword'];
$pass = md5($password);
$cnfpass=md5($cnfpassword);
$emailquery = "select * from users where user_email='$email' ";
$query = mysqli_query($conn,$emailquery);
$emailcount=mysqli_num_rows($query);
if($emailcount>0){
?>
<script>alert("email already registered");</script>
<?php
}
else{
if(preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $email)){
if($pass === $cnfpass){
if(strlen($password)>=4 && strlen($cnfpassword)<=8){
$sql = "insert into users(name,user_name, user_email, password, confirmpassword) values('$name','$username','$email','$pass',' $cnfpass')";
$execute= mysqli_query($conn,$sql);
if($execute)
{
?>
<script>alert("inserted successfully");</script>
<?php
header("location: login.php");
}
else
{
?>
<script>alert("not inserted");</script>
<?php
}
}
else{
?>
<script>alert("password length must contain atleast 4 characters");</script>
<?php
}
}
else{
?>
<script>alert("password not matched");</script>
<?php
}
}
else{
?>
<script>alert ("enter a valid email");</script>
<?php
}
}
}
?>
<html>
<head>
<meta charset="UTF-8">
<title>Register</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="register.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body>
<div id="container-register">
<div id="title">
<i>Register
</div>
<form action="registration.php" method="post">
<div class="input">
<div class="input-addon">
<i class="material-icons">face</i>
</div>
<input id="name" placeholder="Name" name="name" type="text" class="validate" autocomplete="off" required>
</div>
<div class="input">
<div class="input-addon">
<i class="material-icons">email</i>
</div>
` <input id="email" placeholder="Email" name="email" type="email" class="validate" autocomplete="off" required>
</div>
<div class="clearfix"></div>
<div class="input">
<div class="input-addon">
<i class="material-icons">face</i>
</div>
<input id="username" placeholder="Username" name="username" type="text" class="validate" autocomplete="off" required>
</div>
<div class="clearfix"></div>
<div class="input">
<div class="input-addon">
<i class="material-icons">vpn_key</i>
</div>
<input id="password" placeholder="Password" name="password" type="password" class="validate" autocomplete="off" required>
</div>
<div class="input">
<div class="input-addon">
<i class="material-icons">vpn_key</i>
</div>
<input id="cpassword" placeholder="ConfirmPassword" name="confirmpassword" type="password" class="validate" autocomplete="off" required>
</div>
<div class="remember-me">
<input type="checkbox">
<span style="color: #DDD">I accept Terms of Service</span>
</div>
<input type="submit" value="Register" name="register" />
</form>
<div class="privacy">
<a href="#">Privacy Policy</a>
</div>
<div class="register">
Do you already have an account?
<a href="login.php"><button id="register-link">Log In here</button></a>
</div>
</div>
</body>
</html>