-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregistration-action.php
More file actions
90 lines (88 loc) · 3.79 KB
/
Copy pathregistration-action.php
File metadata and controls
90 lines (88 loc) · 3.79 KB
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
<?php
include 'includes/config.php';
if (isset($_POST['registration_action'])) {
$username = sanitizeData($_POST['username']);
$email = sanitizeData($_POST['email']);
$ph = sanitizeData($_POST['ph']);
$city = sanitizeData($_POST['city']);
$address = sanitizeData($_POST['address']);
$role = sanitizeData($_POST['role']);
$pw = sanitizeData($_POST['pass']);
$status = 'de_activated';
if(checkEmail($email)==$email)
{
echo 'Email already exits!';
header( "refresh:1;url=registration.php" );
}
else
{
$conn = new mysqli($DBServer, $DBUser, $DBPass, $DBName);
if ($conn->connect_error) {
trigger_error('Database connection failed: ' .
$conn->connect_error, E_USER_ERROR);
}
$sql="";
if(!empty($_FILES["profile"]["name"]))
{
if ((($_FILES["profile"]["type"] == "image/png") || ($_FILES["profile"]["type"] == "image/jpeg") || ($_FILES["profile"]["type"] == "image/pjpeg"))
&& ($_FILES["profile"]["size"] < 1000000))
{
if ($_FILES["profile"]["error"] > 0)
{
echo "Return Code: " . $_FILES["profile"]["error"] . "<br />";
echo "File error.";
header( "refresh:1;url=registration.php" );
}
else
{
if (file_exists("graphics/" . $_FILES["profile"]["name"]))
{
echo $_FILES["profile"]["name"] . " already exists. ";
$sql="INSERT INTO houser (name,email,ph,city,address,status,pass,role)
VALUES ('$username','$email','$ph','$city','$address','$status','$pw','$role')";
}
else
{
move_uploaded_file($_FILES["profile"]["tmp_name"],
"graphics/" . $_FILES["profile"]["name"]);
echo "Stored in: " . "graphics/" . $_FILES["profile"]["name"];
$pic = $_FILES["profile"]["name"];
$ext = pathinfo($pic, PATHINFO_EXTENSION);
$save_picture = 'profile'.microtime().'.'.$ext;
rename('graphics/'.$pic,'graphics/'.$save_picture);
$sql="INSERT INTO houser (name,email,ph,city,address,status,pass,picture,role)
VALUES ('$username','$email','$ph','$city','$address','$status','$pw','$save_picture','$role')";
}
}
}
else
{
echo "Invalid file type or size!<br>File be jpg/png.";
header( "refresh:1;url=registration.php" );
}
}
else
{
$sql="INSERT INTO houser (name,email,ph,city,address,status,pass,picture,role)
VALUES ('$username','$email','$ph','$city','$address','$status','$pw','nopic','$role')";
}
if($conn->query($sql) === false) {
trigger_error('Wrong SQL: ' . $sql .
' Error: ' . $conn->error, E_USER_ERROR);
header( "refresh:1;url=registration.php" );
} else {
echo 'Your login credentials are sended to your email!';
header( "refresh:2;url=login.php" );
}
$conn->close();
}
}
function checkEmail($email)
{
$db=mysqli_connect($DBServer, $DBUser, $DBPass, $DBName);
$sql="select email from houser where email='".$email."';";
$result = mysqli_query($db,$sql);
$product_array = mysqli_fetch_assoc($result);
return $product_array['email'];
}
?>