-
Notifications
You must be signed in to change notification settings - Fork 1
/
user_signup_db.php
124 lines (80 loc) · 3.49 KB
/
user_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
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
<!-- user signup -->
<?php include "db_connection.php" ?>
<?php
if (isset($_POST['submit'])) {
//insert Data
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$mobile_no = $_POST['mobile_no'];
$password = $_POST['password'];
$password_2 = $_POST['password_2'];
$email = $_POST['email'];
$gender = $_POST['gender'];
//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 = 'images/'.$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";
}
$insert = "";
//email check
if($password == $password_2){
$sql_e = "SELECT * FROM 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 signup (first_name, last_name, mobile_no,email, password, gender, user_img ) VALUES ('$first_name','$last_name','$mobile_no','$email', '$password','$gender', '$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);
}
//get value from database
// $sql = "SELECT * FROM signup";
// $result = mysqli_query($db, $sql);
// if(mysqli_num_rows($result) > 0){
// while($row = mysqli_fetch_assoc($result)) {
// echo "First Name: " .$row["first_name"] ."</br>";
// }
// }
}
mysqli_close($db);
?>