-
Notifications
You must be signed in to change notification settings - Fork 0
/
regesterTest.php
63 lines (55 loc) · 1.82 KB
/
regesterTest.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
<?php
require 'dbConnect.php';
require 'validation.php';
$emailAddress;
$password;
$firstName;
$lastName;
$gender;
$birthYear;
if (isset($_REQUEST['emailAddress']) &&
isset($_REQUEST['password']) &&
isset($_REQUEST['firstName']) &&
isset($_REQUEST['lastName']) &&
isset($_REQUEST['gender']) &&
isset($_REQUEST['birthYear']) &&
validate())
{
$con = makeSQLI();
if($con === false)
die('Error ' . mysqli_connect_error);
$emailAddress = ($_REQUEST['emailAddress']);
$password = (md5($_REQUEST['password']));
$firstName = ($_REQUEST['firstName']);
$lastName = ($_REQUEST['lastName']);
$gender = strtoupper(($_REQUEST['gender']));
$birthYear = ($_REQUEST['birthYear']);
$confCode = md5($emailAddress . rand(1, 50));
$firstName = $_REQUEST['firstName'];
if(mail($_REQUEST['emailAddress'], "Confirm Project Transparency Account",
"Welcome to Project Transparency, $firstName. " .
"We are excited for you to see everything that this project can help you with.
Copy the following link into your browser to activate your account: http://" . $_SERVER['SERVER_NAME'] . "/projectTransperancy/project/activate.php?c=$confCode", 'From: [email protected]'))
echo ("Success");
else
die('Error sending email');
}
else
{
echo "Invalid Data.";
}
function validate()
{
$email = $_REQUEST['emailAddress'];
$password = $_REQUEST['password'];
$firstName = $_REQUEST['firstName'];
$lastName = $_REQUEST['lastName'];
$gender = $_REQUEST['gender'];
$birthYear = $_REQUEST['birthYear'];
return validateEmail($email) && validatePassowrd($password) &&
strlen($firstName) > 0 && strlen($lastName) > 0 &&
strlen($firstName)+strlen($lastName)>3 &&
(strtoupper($gender) == "M" || strtoupper($gender) == "F") &&
(int)$birthYear < date("Y") && (int)$birthYear > 1910;
}
?>