-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.php
More file actions
82 lines (68 loc) · 2.85 KB
/
server.php
File metadata and controls
82 lines (68 loc) · 2.85 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
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "project";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if (isset($_POST['enter']))
{
$name = $_POST['Cname'];
$to_email = $_POST['Email'];
$Mobile = $_POST['Mobile'];
$Hrname = $_POST['Hrname'];
$address = $_POST['address'];
$password = $_POST['password'];
$password_encrypt = md5($password);
$upload_dir = 'uploads'.DIRECTORY_SEPARATOR;
# FIle selecting and uploading
if(array_filter($_FILES['files']['name'])) {
// Loop through each file in files[] array
foreach ($_FILES['files']['tmp_name'] as $key => $value) {
$file_tmpname = $_FILES['files']['tmp_name'][$key];
$file_name = $_FILES['files']['name'][$key];
$file_size = $_FILES['files']['size'][$key];
$file_ext = pathinfo($file_name, PATHINFO_EXTENSION);
$query = "INSERT INTO register (Cname, Email, Mobile, Hrname, address, image, password )
VALUES ('$name', '$to_email', '$Mobile', '$Hrname','$address','$file_name','$password_encrypt')";
mysqli_query($conn, $query);
header('location: index.php');
// Set upload file path
$filepath = $upload_dir.$file_name;
// If file with name already exist then append time in
// front of name of the file to avoid overwriting of file
if(file_exists($filepath)) {
$filepath = $upload_dir.time().$file_name;
if( move_uploaded_file($file_tmpname, $filepath)) {
echo "{$file_name} successfully uploaded <br />";
}
else {
echo "Error uploading {$file_name} <br />";
}
}
else {
if( move_uploaded_file($file_tmpname, $filepath)) {
echo "{$file_name} successfully uploaded <br />";
}
else {
echo "Error uploading {$file_name} <br />";
}
}
}
}
#mail sending ................
$subject = "Simple Email Test via PHP";
$body = "Hi, This is test email send by PHP Script";
$headers = "From: noreply@gmail.com";
#mail sending cuntion and storing files in DB
if (mail($to_email, $subject, $body, $headers)) {
echo "Email successfully sent to $to_email...";
} else {
echo "Email sending failed...";
}
}
?>