-
Notifications
You must be signed in to change notification settings - Fork 1
/
r_signup_db.php
95 lines (70 loc) · 2.45 KB
/
r_signup_db.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
<!-- restaurant signup database-->
<?php include "server_connect.php" ?> <!-- database connect -->
<?php
if (isset($_POST['submit'])) {
//insert Data
$r_name = $_POST['r_name'];
$mobile_no = $_POST['mobile_no'];
$password = $_POST['password'];
$password_2 = $_POST['password_2'];
$email = $_POST['email'];
$r_address = $_POST['r_address'];
$insert = "";
//image upload
$fileName = $_FILES['file'] ['name'];
$fileTmpName = $_FILES['file'] ['tmp_name'];
$fileSize = $_FILES['file'] ['size'];
$fileError = $_FILES['file'] ['error'];
$fileType = $_FILES['file'] ['type'];
$fileExt = explode('.', $fileName);
$fileActualExt = strtolower(end($fileExt));
$allowed = array('jpg', 'jpeg', 'png');
if (in_array($fileActualExt, $allowed)) {
if ($fileError === 0) {
if ($fileSize < 5000000) {
$fileNameNew = uniqid('', true).".".$fileActualExt;
$fileDestination = 'resource/'.$fileNameNew;
move_uploaded_file($fileTmpName, $fileDestination);
//header("Location: show_image.php?uploadsuccess");
echo "uploaded";
}
else{
echo "Your file is too big!";
}
}else {
echo "There was an error uploading your file!";
}
} else {
echo "File extension error. Try to upload jeg, jpeg or png extension file";
}
//email check
if($password == $password_2){
$sql_e = "SELECT * FROM r_signup WHERE email='$email'";
$res_e = mysqli_query($db, $sql_e);
if(mysqli_num_rows($res_e) > 0){
echo "Sorry... email already taken";
}else{
$password = md5($password);
$insert = "INSERT INTO r_signup (r_name, mobile_num, email, r_password, r_address, r_img) VALUES ('$r_name','$mobile_no','$email', '$password', '$r_address', '$fileDestination')";
$results = mysqli_query($db, $insert);
var_dump($insert);
if ($results) {
// echo 'Saved!';
header("Location:signup_success.php");
}else{
echo mysqli_error($db);
echo "Not saved!";
}
exit();
}
}else{
echo "Error: your password didn't match";
}
if (mysqli_multi_query($db, $insert)) {
echo "record created";
}else{
echo "error: ". $insert. mysqli_error($db);
}
}
mysqli_close($db);
?>