-
Notifications
You must be signed in to change notification settings - Fork 1
/
NonMemberDonation.php
139 lines (110 loc) · 4.26 KB
/
NonMemberDonation.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {font-family: Arial, Helvetica, sans-serif;}
* {box-sizing: border-box;}
input[type=text], select, textarea {
width: 100%;
padding: 12px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
margin-top: 6px;
margin-bottom: 16px;
resize: vertical;
}
input[type=submit] {
background-color: #4CAF49;
color: white;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type=submit]:hover {
background-color: #45a048;
}
.container {
border-radius: 5px;
background-color: #f2f2f1;
padding: 20px;
}
</style>
</head>
<body>
<h3>Non-Member Donation</h3>
<div class="container">
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<!--form action="hello.php" method="post" /-->
<label for="ProjectID">Project ID </label>
<input type="text" id="ProjectID" name="ProjectID" placeholder="ProjectID">
<label for="amount">Amount</label>
<input type="text" id="amount" name="amount" placeholder="amount">
<label for="BankSlip">Bank Slip</label>
<input type="text" id="BankSlip" name="BankSlip" placeholder="BankSlip">
<label for="fullname">Full Name</label>
<input type="text" id="fullname" name="fullname" placeholder="fullname">
<label for="NIC">NIC</label>
<input type="text" id="NIC" name="NIC" placeholder="NIC">
<label for="email">Email</label>
<input type="text" id="email" name="email" placeholder="Email">
<label for="pnumber">Phone Number</label>
<input type="text" id="pnumber" name="pnumber" placeholder="pnumber">
</select>
<input type="submit" value="Submit">
</form>
</div>
</body>
</html>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$ProjectID=$_POST['ProjectID'];
echo "ProjectID: ".$ProjectID."<br>";
$amount=$_POST['amount'];
echo "Amount: ".$amount."<br>";
$BankSlip=$_POST['BankSlip'];
echo "Bank Slip: ".$BankSlip."<br>";
$fullname=$_POST['fullname'];
echo "fullname: ".$fullname."<br>";
$NIC=$_POST['NIC'];
echo "NIC: ".$NIC."<br>";
$email=$_POST['email'];
echo "email: ".$email."<br>";
$pnumber=$_POST['pnumber'];
echo "pnumber: ".$pnumber."<br>";
$UserID='NotAMember';
$servername = "localhost"; // host which has established our computer.If the database is on a sever, then this should change accordinly
$username = "root"; // username and the password of the mysql sever
$password = "";
$dbname = "SamajaSathkara";
$conn = new mysqli($servername,$username,$password,$dbname); // making the connection with mysql
if ($conn->connect_error){ // check whether the connection is correctly established or not
die("Connection failed: " . $conn->connect_error);
} // upto here ,connection is established
$c="'";
$date=strval(date("Y-m-d"));
$time= strval(date("H:i:s"));
//$date1=strval(date("Ymd"));
//$time1= strval(date("His"));
//$projectid= "project".$date1.$time1;
$sql = "INSERT INTO Donation(ProjectID,amount,submitdate,submittime,BankSlip,isMember,UserID,fullname,NIC,email,pnumber,approved) VALUES ('$ProjectID','$amount','$date','$time','$BankSlip',false,'$UserID','$fullname','$NIC','$email','$pnumber',false)"; // insert data to the created table
//$sql = "INSERT INTO Projects (completed ,createdate ,cratetime ,projectname ,estimatedprojectcost ,raised ,projectid) VALUES (false,'$date','$time','$projectname','$estimatedprojectcost','$raised','$projectid')"; // insert data to the created table
if ($conn->query($sql)===TRUE){
echo "<h3>Donation has been sucessfully created";
}else{
echo "Error: ". $sql ."<br>" . $conn->error;
}
/*$sql = "SELECT firstname,lastname,email,pnumber FROM ContactForm"; //reading things from the table
$result = $conn->query($sql);
if ($result->num_rows > 0){
while($row = $result->fetch_assoc()){ //while loop
echo "firstname: ". $row["firstname"]."<br>"." lastname: " . $row["lastname"]."<br>"."email: ".$row["email"]."<br>"."pnumber: ".$row["pnumber"]."<br>"."<br>";
}
}else{
echo "0 results";
}*/
$conn->close(); //close the connection with database
}
?>