-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_donor.php
157 lines (116 loc) · 3.94 KB
/
edit_donor.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
include('dbcon.php');
// get id value which is send with url
if (isset($_GET["id"]) && $_GET["id"] != "" ) {
$id = intval($_GET["id"]);
// echo $id;
// retrive data according to id
$sql = "Select * from donor Where id = $id";
$result = $connection -> query($sql);
if ($result-> num_rows > 0) {
while ($row = $result -> fetch_assoc()) {
$medicine=$row['do_medicine'];
$edate=$row['do_date'];
$company=$row['do_manufacturer'];
$quantity=$row['do_quantity'];
$city=$row['do_city'];
$pharmasy=$row['do_pharmacy'];
}
}else {
echo "No Recrd Found".$connection->error;
}
}else {
die("No valid user ID found");
}
?>
<!---------------------------->
<!--html start-->
<!---------------------------->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="samra_anwar.css">
</head>
<body>
<!--internal css-->
<style>
.Donor_bg {
height: 120vh;
}
</style>
<div class="Donor_bg">
<div id="container">
<div id="header">
<h1>Donate Medicine or Help Messes </h1>
</div>
<div id="nav">
<ul>
<li> <a href="dashboard.php"><b>Home</b></a></li>
<li> <a href="donor.php"><b>Donor</b> </a></li>
<li><a href="receive.php"><b>Receiver</b> </a></li>
<li><a href="about.php"> <b>About</b> </a></li>
<li> <a href="signup.php"><b>login/signup</b> </a></li>
</ul>
</div>
</div>
<div class="form">
<form action="update_donor.php" method="post">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div class="field-wrap">
<input type="text" name="medicine" value="<?php echo $medicine; ?>" placeholder="name of medicine">
</div>
<div class="field-wrap">
<input type="date" name="edate" value="<?php echo $edate; ?>" placeholder="exp date of medicine">
</div>
<div class="field-wrap">
<input type="text" name="company" value="<?php echo $company; ?>" placeholder="manufacturer">
</div>
<div class="field-wrap">
<input type="text" value="<?php echo $quantity; ?>" name="quantity" placeholder="quantity of medicine">
</div>
<div class="field-wrap">
<input type="text" name="city" value="<?php echo $city; ?>" placeholder="name of city">
</div>
<div class="field-wrap">
<input type="text" name="pharmasy" value="<?php echo $pharmasy; ?>" placeholder="name of pharmasy">
</div>
<button type="submit" class="button button-block" name="submit" />Edit Donate</button>
</form>
</div><
</div>
</div>
</div>
</body>
<!---------------------------->
<!--php start-->
<!---------------------------->
<?php
include('dbcon.php');
if(isset($_POST['submit'])){
$medicine=$_POST['medicine'];
$edate=$_POST['edate'];
$company=$_POST['company'];
$quantity=$_POST['quantity'];
$city=$_POST['city'];
$pharmasy=$_POST['pharmasy'];
// insert data
$qry1="INSERT INTO `donor`(`do_medicine`, `do_date`,`do_manufacturer`, `do_quantity`,`do_city`, `do_pharmacy`) VALUES ('$medicine','$edate','$company','$quantity','$city','$pharmasy')";
// execute query and show results or error
if ($connection->query($qry1) === TRUE) {
echo "Medicine Donated Successfully";
}else{
echo "Error in inserting: ".$connection->error;
}
}
?>
<!---------------------------->
<!--php end-->
<!---------------------------->
</html>
<!---------------------------->
<!--html end-->
<!---------------------------->