-
Notifications
You must be signed in to change notification settings - Fork 0
/
don.php
64 lines (55 loc) · 1.49 KB
/
don.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
<?php
$host='localhost';
$dbusername='root';
$dbpassword='';
$dbname='pari';
$food = $_POST['foodJson'];
$medicines = $_POST['medsJson'];
$daily = $_POST['needsJson'];
$username = $_POST['username'];
$address = $_POST['useraddress'];
$mobile = $_POST['mobileno'];
$conn = mysqli_connect($host,$dbusername,$dbpassword, $dbname);
/*if(!$con)
{
echo "Not Connected to Server";
}
if(!mysqli_select_db($con,$dbname))
{
echo " DB not selected";
$food = $_POST['food'];
$medicines = $_POST['medicines'];
$daily = $_POST['daily'];
$assistance = $_POST['assistance'];
$sql = "INSERT INTO Request (Food,Medicine,DailyNeeds,RequestR) VALUES ('$food','$medicines','$daily','$assistance')";
if(!mysqli_query($con,$sql))
{
echo 'Not Inserted';
}
else
{
echo'Inserted';
}
$con->close*/
if($conn->connect_error)
{
die('Connection Failed :'.$conn->connect_error);
}
else{
$dateOfYear = date('Y/m/d');
$dateOfYear = explode('/',$dateOfYear);
$date = $dateOfYear[2];
$month = $dateOfYear[1];
$year = $dateOfYear[0];
$finalDate = $date."".$month."".$year;
$random = rand(100,999);
$donationId = $finalDate."".$random;
$stmt = $conn->prepare("INSERT INTO donations (donationId,username,mobileno,useraddress,food,medicines,dailyneeds) VALUES (?,?,?,?,?,?,?) ");
$stmt->bind_param("sssssss",$donationId,$username,$mobile,$address,$food,$medicines,$daily);
$stmt->execute();
echo " Registration Succcess. Your Donation Id is".$donationId;
$stmt->close();
$conn->close();
}
header( "refresh:5;url=index.html" );
?>