-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverify_signup.php
151 lines (138 loc) · 4.21 KB
/
verify_signup.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
<?php
require "config.php";
echo '<html><head><link rel="stylesheet" type="text/css" href="styles/main.css"></head><body>';
//Get the user username
//*********************************************
$username = "";
if(array_key_exists("username",$_POST))
{
$username = $_POST['username'];
}
else if(array_key_exists("username",$_GET))
{
$username = $_GET['username'];
}
else
{
die("Please enter a username!");
}
//*****************************************
//Get the user password
//*********************************************
$password = "";
if(array_key_exists("password",$_POST))
{
$password = $_POST['password'];
}
else if(array_key_exists("password",$_GET))
{
$password = $_GET['password'];
}
else
{
die("Please enter a password!");
}
//*****************************************
//Get the user firstname
//*********************************************
$firstname = "";
if(array_key_exists("firstname",$_POST))
{
$firstname = $_POST['firstname'];
}
else if(array_key_exists("firstname",$_GET))
{
$firstname = $_GET['firstname'];
}
else
{
die("Please enter a firstname!");
}
//*****************************************
//Check whether the username is allready taken
$result = mysql_query("select * from users where users_username = '".$username."'");
if(mysql_num_rows($result) != 0)
{
die("<h1>UserName is already taken!</br>");
}
//Add user to the database
$result = mysql_query("insert into users(users_username,users_password,users_firstname) values('".$username."','".$password."','".$firstname."')");
//Get the user last name
//*********************************************
$lastname = "";
if(array_key_exists("lastname",$_POST))
{
$lastname = $_POST['lastname'];
}
else if(array_key_exists("lastname",$_GET))
{
$lastname = $_GET['lastname'];
}
//*****************************************
//add name to the database
if($lastname != "")
$result = mysql_query("update users set users_lastname = '".$lastname."' where users_username = '".$username."'");
//Get the user email address
//*********************************************
$email = "";
if(array_key_exists("email",$_POST))
{
$email = $_POST['email'];
}
else if(array_key_exists("email",$_GET))
{
$email = $_GET['email'];
}
//*****************************************
//add name to the database
if($email != "")
$result = mysql_query("update users set users_email = '".$email."' where users_username = '".$username."'");
//get the user photo url
if(isset($_FILES['image']))
{
$errors= array();
$file_name = $_FILES['image']['name'];
if($file_name != "")
{
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$expensions= array("jpeg","jpg","png");
if(in_array($file_ext,$expensions)=== false)
{
$errors[]="extension not allowed, please choose a JPEG or PNG file.";
}
if($file_size > 2097152)
{
$errors[]='File size must be excately 2 MB';
}
if(empty($errors)==true)
{
//generate a new name that was not taken before
$i = 0;
while(file_exists("photos/".$i.$file_name))
{
$i++;
}
$file_name = $i.$file_name;
//*********************************************
move_uploaded_file($file_tmp,"photos/".$file_name);
//echo "Success ".$file_name;
}
else
{
print_r($errors);
die("!");
}
}
else
{
$file_name = 'nophoto.png';
}
}
$result = mysql_query("update users set users_photourl = 'photos/".$file_name."' where users_username = '".$username."'");
printf("<h1>Thank you for registration!</h1>");
printf('<a href="index.php">Back to homepage</a>');
echo '</body>';
?>