/
index.php
159 lines (127 loc) · 4.99 KB
/
index.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
155
156
157
158
159
<?php
ob_start();
session_start();
error_reporting(E_ALL);
include("root.php");
include(SITE_ROOT . "/classes/validate-fields.php");//INPUT VALIDATION CLASS
$validator = new validate();//CREATING VALIDATION OBJECT
$titleText = "Register Yourself";
$firstname = "";
$lastname = "";
$address1 = "";
$address2 = "";
$city = "";
$state = "";
$zipcode = "";
$form = SITE_ROOT."/forms/registration.php";//FIRST REGISTRATION FORM
$form1 = SITE_ROOT."/forms/registration-confirm.php";//CONFIRM FIRST REGISTRATION FORM
$errorMsg = "";
?>
<!-- *********************** START HTML DECLARATION *********************************-->
<!DOCTYPE html>
<html>
<head>
<title><?php echo $titleText;?></title>
<META NAME="Keywords" CONTENT="registration">
<META NAME="Description" CONTENT="This is a simple registration form">
<meta name="robots" content="noindex, nofollow">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo SITE_URL?>/javascript/registration.js"></script>
<script type="text/javascript" src="<?php echo SITE_URL?>/javascript/jquery.validate.min.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo SITE_URL?>/css/style.css">
<link rel="stylesheet" type="text/css" href="<?php echo SITE_URL?>/css/style1.css">
<link rel="stylesheet" type="text/css" href="<?php echo SITE_URL?>/css/bootstrap.css">
<!-- *********************** END HTML DECLARATION *********************************-->
</head>
<body>
<div id="page-wrap">
<div id="content">
<?php
///////////////////////// SHOWING SUCCESS RESULT AFTER VERIFICATION IN SESSION ////////////////
if(isset($_SESSION['success'])){
echo "<center><font style='font-size:16px;font-family:verdana;font-weight:bold'>You have successfully registered.</font></center><br />";
unset($_SESSION['success']);
}
///////////////////////// SUBMITTING CONFIRM FORM AFTER CONFIRMING ////////////////
if(isset($_REQUEST['formSubmittedConfirm'])){
extract($_REQUEST);
$t_firstname = addslashes(trim($firstname));
$t_lastname = addslashes(trim($lastname));
$t_address1 = addslashes(trim($address1));
$t_address2 = addslashes(trim($address2));
$t_city = addslashes(trim($city));
$t_state = addslashes(trim($state));
$t_zipcode = addslashes(trim($zipcode));
$zipcount = strlen($zipcode);
if($isBackedClick == 1){
include($form);
}
else{
$validator ->checkField($firstname,"","Please enter your first name.");
$validator ->checkField($lastname,"","Please enter your last name.");
$validator ->checkField($address1,"","Please enter your address1.");
$validator ->checkField($city,"","Please enter your first city.");
$validator ->checkField($state,"","Please select your state.");
$validator ->checkField($zipcode,"","Please enter your zip code.");
if(!empty($zipcode) && ($zipcount != 5 && $zipcount != 9)){
$validator->setError("Please enter your zip code with 5 or 9 digits.");
}
$errorMsg = $validator ->getErrors();
$dataValid = $validator ->isDataValid();
if($dataValid){
//ADDING IN DATABASE
$query = "INSERT INTO users SET firstname='$firstname',lastname='$lastname',address1='$address1',address2='$address2',city='$city',state='$state',zipcode=$zipcode,visitorIP='".VISITOR_IP_ADDRESS."',registeredOn='".CURRENT_DATE_CUSTOMER_ZONE."',registeredTime='".CURRENT_TIME_CUSTOMER_ZONE."'";
mysql_query($query);
$_SESSION['success'] = 1;
ob_clean();
header("Location: ".SITE_URL);
exit();
}
else{
include($form);
}
}
}
else{
///////////////////////// SUBMITTING FIRST FORM ////////////////
if(isset($_REQUEST['formSubmitted'])){
extract($_REQUEST);
$t_firstname = addslashes(trim($firstname));
$t_lastname = addslashes(trim($lastname));
$t_address1 = addslashes(trim($address1));
$t_address2 = addslashes(trim($address2));
$t_city = addslashes(trim($city));
$t_state = addslashes(trim($state));
$t_zipcode = addslashes(trim($zipcode));
$zipcount = strlen($zipcode);
$validator ->checkField($firstname,"","Please enter your first name.");
$validator ->checkField($lastname,"","Please enter your last name.");
$validator ->checkField($address1,"","Please enter your address1.");
$validator ->checkField($city,"","Please enter your first city.");
$validator ->checkField($state,"","Please select your state.");
$validator ->checkField($zipcode,"","Please enter your zip code.");
if(!empty($zipcode) && ($zipcount != 5 && $zipcount != 9)){
$validator->setError("Please enter your zip code with 5 or 9 digits.");
}
$errorMsg = $validator ->getErrors();
$dataValid = $validator ->isDataValid();
if($dataValid){
include($form1);
}
else{
include($form);
}
}
else{
include($form);
}
}
?>
</div>
</div>
</div> <!-- end page wrap -->
<footer>
<center>© Copyright <?php echo date('Y');?> Registration Project. All rights reserved.</center>
</footer>
</body>
</html>