-
Notifications
You must be signed in to change notification settings - Fork 0
/
final_image.php
53 lines (38 loc) · 1.55 KB
/
final_image.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
<?php
$name=$_POST['Name'];
$email=$_POST['Email'];
$mobile=$_POST['Mobile'];
$address=$_POST['address'];
$description=$_POST['description'];
$city=$_POST['city'];
//if(isset($_POST["submit"])){
$check = getimagesize($_FILES["image"]["tmp_name"]);
if($check !== false){
$image = $_FILES['image']['tmp_name'];
$imgContent = addslashes(file_get_contents($image));
/*
* Insert image data into database
*/
//DB details
$dbHost = 'localhost';
$dbUsername = 'root';
$dbPassword = '';
$dbName = 'helping_hands';
//Create connection and select DB
$db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);
// Check connection
if($db->connect_error){
die("Connection failed: " . $db->connect_error);
}
//$dataTime = date("Y-m-d H:i:s");
//Insert image content into database
$insert = $db->query("INSERT into homeless_register (name, email , contact_number ,address , description ,person_image, city) VALUES ('$name', '$email','$mobile','$address','$description','$imgContent','$city')");
if($insert){
echo "homeless registration successful.";
}else{
echo "File upload failed, please try again.";
}
}else{
echo "Please select an image file to upload.";
}
?>