-
Notifications
You must be signed in to change notification settings - Fork 0
/
createAccount.php
50 lines (40 loc) · 1.14 KB
/
createAccount.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
<?php
require 'connect.php';
$username = htmlspecialchars($_POST['username']);
$email = htmlspecialchars($_POST['email1']);
$pass1 = htmlspecialchars(md5($_POST['password1']));
$pass2 = htmlspecialchars(md5($_POST['password2']));
if(checkPass($pass1,$pass2) == true && checkEmail($email) == false){
$database = new connect();
$query = "INSERT INTO users(name,email,password)VALUES('$username','$email','$pass1')";
$resultQuery = mysql_query($query);
//header("location:registration.php?success");
echo "registered";
}else{
//header("Location:registration.php?fail");
echo $username." ".$email." ".$pass1." ".$pass2;
}
/*
* checking passwords
*/
function checkPass($p1 , $p2){
$result = false;
if($p1 == $p2){
$result = true;
}
return $result;
}
/*
* checking email in the database
*/
function checkEmail($email){
$database = new connect();
$result = false;
$query = "SELECT * FROM users WHERE email='$email'";
$resultQuery = mysql_query($query);
if(mysql_num_rows($resultQuery) == 1){
$result = true;
}
return $result;
}
?>