forked from tejus13/Social
/
index.php
128 lines (128 loc) · 4.15 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
<?php
//including the necessary files
include 'Core/connection.php' ;
include 'Core/Functions/functions.php' ;
include 'Core/init.php' ;
//code to process data from register form
if ((empty($_POST) === false) and ($_POST['form_type'] === 'register')) {
$first_name = secure_data($_POST['first_name']) ;
$last_name = secure_data($_POST['last_name']) ;
$user_name = secure_data($_POST['user_name']) ;
$email = secure_data($_POST['email']) ;
$password = secure_data($_POST['password']) ;
if (strlen($first_name) > 100) {
$errors[] = 'First Name must be less than 100 characters' ;
}
if (strlen($last_name) > 100) {
$errors[] = 'Last Name must be less than 100 characters' ;
}
if (strlen($user_name) > 100) {
$errors[] = 'User Name must be less than 100 characters' ;
}
if (strlen($password) > 100) {
$errors[] = 'Password must be less than 100 characters' ;
}
if (email_exists($database_handler , $email)) {
$errors[] = 'The given Email already exists' ;
}
if (user_exists($database_handler , $user_name)) {
$errors[] = 'The given User Name already exists' ;
} else {
$user_details = array(
'user_name' => $user_name ,
'user_first_name' => $first_name ,
'user_last_name' => $last_name ,
'user_email' => $email ,
'user_email_code' => md5($email) ,
'user_password' => $password
) ;
register_user($database_handler , $user_details) ;
}
}
?>
<!DOCTYPE html>
<HTML>
<HEAD>
<META charset="UTF-8" />
<TITLE>Social</TITLE>
<LINK href = 'http://fonts.googleapis.com/css?family=Titillium+Web:400,300,600' rel = 'stylesheet' type = 'text/css' />
<LINK rel = "stylesheet" href = "CSS/Login And Register/normalize.css" />
<LINK rel = "stylesheet" href = "CSS/Login And Register/style.css" />
</HEAD>
<BODY>
<DIV class = "form">
<UL class = "tab-group">
<LI class = "tab active">
<A href = "#signup">Sign Up</A>
</LI>
<LI class = "tab">
<A href = "#login">Log In</A>
</LI>
</UL>
<DIV class = "tab-content">
<DIV id = "signup">
<H1>Sign Up for Free</H1>
<FORM action = "" method = "post">
<INPUT type = "hidden" name = "form_type" value = "register" />
<DIV class = "top-row">
<DIV class = "field-wrap">
<LABEL>
First Name<SPAN class = "req">*</SPAN>
</LABEL>
<INPUT type = "text" name = "first_name" required autocomplete = "on" />
</DIV>
<DIV class = "field-wrap">
<LABEL>
Last Name<SPAN class = "req">*</SPAN>
</LABEL>
<INPUT type = "text" name = "last_name" required autocomplete = "on"/>
</DIV>
</DIV>
<DIV class = "field-wrap" align = "center">
<LABEL>
User Name<SPAN class = "req">*</SPAN>
</LABEL>
<INPUT type = "text" name = "user_name" required autocomplete = "on" />
</DIV>
<DIV class = "field-wrap">
<LABEL>
Email Address<SPAN class = "req">*</SPAN>
</LABEL>
<INPUT type = "email" name = "email" required autocomplete = "on"/>
</DIV>
<DIV class = "field-wrap">
<LABEL>
Set A Password<SPAN class = "req">*</SPAN>
</LABEL>
<INPUT type = "password" name = "password" required autocomplete = "on"/>
</DIV>
<BUTTON type = "submit" class="button button-block"/>Get Started</BUTTON>
</FORM>
</DIV>
<DIV id = "login">
<H1>Welcome Back!</H1>
<FORM action = "" method = "post">
<DIV class = "field-wrap">
<LABEL>
Email Address<SPAN class = "req">*</SPAN>
</LABEL>
<INPUT type = "email" required autocomplete = "off"/>
</DIV>
<DIV class = "field-wrap">
<LABEL>
Password<SPAN class = "req">*</SPAN>
</LABEL>
<INPUT type = "password" required autocomplete = "off"/>
</DIV>
<P class = "forgot">
<A href = "#">Forgot Password?</A>
</P>
<BUTTON class = "button button-block"/>Log In</BUTTON>
</FORM>
</DIV>
</DIV><!-- tab-content -->
</DIV> <!-- /form -->
<SCRIPT src = 'http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></SCRIPT>
<SCRIPT src = "JS/Login And Register/index.js"></SCRIPT>
</BODY>
</HTML>