-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdonate.php
More file actions
77 lines (58 loc) · 2.04 KB
/
donate.php
File metadata and controls
77 lines (58 loc) · 2.04 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
<!DOCTYPE html>
<html>
<body>
<?php
// define variables to empty values
$nameErr = $emailErr = $mobilenoErr = $genderErr = $websiteErr = $agreeErr = "";
$name = $email = $mobileno = $gender = $website = $agree = "";
if($_SERVER["REQUEST_METHOD"]=='POST'){
$userid=$_POST["newid"];
$val=$_POST["dona"];
$amount=$_POST["amt"];
}
$servername = "localhost";
$username = "root";
$password = "";
$database="HumanTeam";
// Create a connection
$conn = mysqli_connect($servername, $username, $password,$database);
// Die if connection was not successful
if (!$conn){
die("Sorry we failed to connect: ". mysqli_connect_error());
}
else{
echo "Connection was successful<br>";
//submit data to database
if($val=='Amount'){
$sql1="INSERT INTO `donations`(`Amount`, `id`, `amount_id`) VALUES ('$amount', '$userid', NULL)";
$result=mysqli_query($conn,$sql1);
if($result){
echo "Your entry has been submitted successfully";
}else{
echo "The record has not been inserted successfully error -->".mysqli_error($conn);
//echo "Website cannot load due to technical issues!";
}
}else{
echo "Thank you .Please contact Phone no:9837534545 for further details`";
}
}
?>
<form action="donate.php" method="POST" >
<h4>Donate according to your will,any form of donations for essential goods or funds will be accepted"</h4>
<label for="newid">User ID</label><br>
<input type="text" id="newid" name="newid"><br><br>
<br>
<h3>Form of Donation</h3>
<select id="dona" name="dona">
<option value="Amount">Amount</option>
<option value="Clothes">Clothes</option>
<option value="Books">Books</option>
<option value="Toys">Toys</option>
</select>
<br>
<label for="amt">If you are donating amount kindly enter amount that you are goin to donate</label>
<input type="text" id="amt" name="amt"><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>