forked from ringelweb/RingelNew
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseller_reg2.php
154 lines (96 loc) · 4.07 KB
/
seller_reg2.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
require 'includes/connect.php';
//Declaring variables to prevent error
$user_id="";
$pass_1 = "";
$pass_2 = "";
$error_array = array();
if(isset($_POST['user_reg'])){
$user_id = strip_tags($_POST['user_name']);
//$_SESSION['user_name'] = $user_id;
$pass_1 = strip_tags($_POST['pass1']);
$pass_2 = strip_tags($_POST['pass2']);
if($pass_1 != $pass_2) {
array_push($error_array, "Your passwords dont match<br>");
}
else{
if(preg_match('/[^A-Za-z0-9]/', $pass_1)){
array_push($error_array, "Your password can only contain english characters or numbers<br>");
}
}
if( strlen($pass_1) > 40 || strlen($pass_1) < 5 ) {
array_push($error_array, "Your password must be between 5 and 40 characters<br>");
}
if(empty($error_array)) {
$pass_1 = md5($pass_1);
}
$check_username_query = mysqli_query($con,"SELECT username FROM users WHERE username = '$user_id'");
$count = mysqli_num_rows($check_username_query);
if($count > 0)
array_push($error_array, "This user id is taken...<br>");
if(empty($error_array)) {
//$query =mysqli_query($con,"INSERT INTO users VALUES ('','$user_id','$pass_1')");
$query ="INSERT INTO users(username,password) VALUES ('$user_id','$pass_1')";
$seller_registration_submit = mysqli_query($con, $query) or die(mysqli_error($con));
//session_start();
//$_SESSION['user_name'] =$user_id;
header("Location: index.php?msg=Registration Successful!");
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>RINGEL</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<?php include ("includes/header.php") ?>
<div class="container margin-container div-hover">
<center> <img src="img/icons/security.png" width="200px"></center>
<div class="col-sm-9 col-sm-offset-3"style="padding-left:90px;"><h3>Create Username and Password</h3></div>
<form class="form-horizontal col-sm-9 col-sm-offset-3" id = "" action="seller_reg2.php" method="POST">
<br>
<div class="form-group">
<label class="control-label xx-2 col-sm-2" >Username:</label>
<div class="xx-1 col-sm-5">
<input type="text" class="form-control" placeholder="Pick a Username" name="user_name" value="<?php
if(isset($_SESSION['user_name'])) {
echo $_SESSION['user_name'];
}
?>" required>
<br>
<?php if(in_array("This user id is taken...<br>", $error_array)) echo "This user id is taken...<br>";?>
</div>
</div>
<div class="form-group">
<label class="control-label xx-2 col-sm-2" >Password:</label>
<div class="xx-1 col-sm-5">
<input type="password" class="form-control" placeholder="****" name="pass1" required>
</div>
</div>
<div class="form-group">
<label class="control-label xx-2 col-sm-2" >Confirm Password:</label>
<div class="xx-1 col-sm-5">
<input type="password" class="form-control" placeholder="****" name="pass2" required>
<br>
<?php if(in_array("Your passwords dont match<br>", $error_array)) echo "Your passwords dont match<br>";
else if(in_array("Your password can only contain english characters or numbers<br>", $error_array)) echo "Your password can only contain english characters or numbers<br>";
else if(in_array("Your password must be between 5 and 40 characters<br>", $error_array)) echo "Your password must be between 5 and 40 characters<br>";?>
</div>
</div>
<div class="form-group">
<div class=" xx-2 col-sm-8">
<input type="submit" class="btn btn-lg btn-block btn-success " value="Register" name="user_reg">
</div>
</div>
</form>
</div>
<br><br>
<?php include 'includes/footer.php'; ?>
</body>
</html>