-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsign-up2.php
142 lines (133 loc) · 4.79 KB
/
sign-up2.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
<?php
require_once 'dbconfig.php';
if($user->is_loggedin()!="")
{
$user->redirect('home.php');
}
if(isset($_POST['btn-signup']))
{
$fname = trim($_POST['fname']);
$lname = trim($_POST['lname']);
$uname = trim($_POST['uname']);
$city = trim($_POST['city']);
$birthday= trim($_POST['birthday']);
$creditCardNumber = trim($_POST['creditCardNumber']);
$ccv = trim($_POST['ccv']);
$uemail = trim($_POST['email']);
$upassword = trim($_POST['pwd']);
if($uname=="") {
$error[] = "provide username !";
}else if($uemail=="") {
$error[] = "provide email id !";
}
else if(!filter_var($uemail, FILTER_VALIDATE_EMAIL)) {
$error[] = 'Please enter a valid email address !';
}
else if($upassword=="") {
$error[] = "provide password !";
}
else if(strlen($upassword) < 6){
$error[] = "Password must be atleast 6 characters";
}
else
{
try
{
$stmt = $DB_con->prepare("SELECT username,email FROM user WHERE username=:uname OR email=:email");
$stmt->execute(array(':uname'=>$uname, ':email'=>$uemail));
$row=$stmt->fetch(PDO::FETCH_ASSOC);
if($row['username']==$uname) {
$error[] = "sorry username already taken !";
}
else if($row['email']==$uemail) {
$error[] = "sorry email id already taken !";
}
else
{
if($user->register($fname,$lname,$uname,$city,$birthday,$creditCardNumber,$ccv,$uemail,$upassword))
{
$user->redirect('sign-up.php?joined');
}
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sign up : cleartuts</title>
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div class="container">
<div class="form-container">
<form method="post">
<h2>Sign up.</h2><hr />
<?php
if(isset($error))
{
foreach($error as $error)
{
?>
<div class="alert alert-danger">
<i class="glyphicon glyphicon-warning-sign"></i> <?php echo $error; ?>
</div>
<?php
}
}
else if(isset($_GET['joined']))
{
?>
<div class="alert alert-info">
<i class="glyphicon glyphicon-log-in"></i> Successfully registered <a href='index.php'>login</a> here
</div>
<?php
}
?>
<div class="form-group">
<input type="text" class="form-control" name="fname" placeholder="Enter First Name" />
</div>
<div class="form-group">
<input type="text" class="form-control" name="lname" placeholder="Enter Last Name" />
</div>
<div class="form-group">
<input type="text" class="form-control" name="uname" placeholder="Enter UserName" />
</div>
<div class="form-group">
<input type="text" class="form-control" name="city" placeholder="Enter city" />
</div>
<div class="form-group">
<input type="text" class="form-control" name="birthday" placeholder="Enter your birthday" />
</div>
<div class="form-group">
<input type="text" class="form-control" name="creditCardNumber" placeholder="Enter credit card details" />
</div>
<div class="form-group">
<input type="text" class="form-control" name="ccv" placeholder="Enter ccv" />
</div>
<div class="form-group">
<input type="text" class="form-control" name="email" placeholder="Enter E-Mail ID" value="<?php if(isset($error)){echo $uemail;}?>" />
</div>
<div class="form-group">
<input type="password" class="form-control" name="pwd" placeholder="Enter Password" />
</div>
<div class="clearfix"></div><hr />
<div class="form-group">
<button type="submit" class="btn btn-block btn-primary" name="btn-signup">
<i class="glyphicon glyphicon-open-file"></i> SIGN UP
</button>
</div>
<br />
<label>have an account ! <a href="index.php">Sign In</a></label>
</form>
</div>
</div>
</body>
</html>