-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_savings.php
75 lines (63 loc) · 1.82 KB
/
update_savings.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
<?php
session_start();
$conn=mysqli_connect("localhost","root","","moneyliteracy")or die("Can't Connect...");
$id=$_GET['sid'];
$q="SELECT savings_date, savings_details, savings_total from savings WHERE savings_id = $id";
$res=mysqli_query($conn, $q) or die("Can't Execute Query...");
$row = mysqli_fetch_assoc($res);
mysqli_free_result($res);
?>
<!DOCTYPE html>
<html>
<head>
<title>EDIT SAVINGS</title>
<style>
h1{
text-align:center;
font-family: arial;
font-weight:bold;
}
form{
background-color: white;
margin:5% 30%;
border-radius:10px;
border:2px solid grey;
padding:10px 20px;
}
a:hover{
color:red;
cursor:pointer;
}
</style>
</head>
<body>
<h1>UPDATE YOUR SAVINGS</h1>
<form method="post">
<label>Date:</label><input type="datetime-local" name="date" value="<?php echo $row['savings_date'];?>"><br><br>
<label>Amount of savings for today:</label><input type="text" name="total" value="<?php echo $row['savings_total'];?>" size="10"><br><br>
<label>Details:</label><input type="text" name="details" value="<?php echo $row['savings_details'];?>" size="10"><br><br>
<input type="button" name="cancel" value="CANCEL" onClick="window.location='student_savings.php';"/>
<input name="pls" type="submit" value="SUBMIT">
</form>
<?php
if(isset($_POST["pls"]))
{
$date=$_POST["date"];
$total=$_POST["total"];
$details=$_POST["details"];
$q="UPDATE savings SET savings_date='$date', savings_total='$total' , savings_details='$details' where savings_id='$id'";
mysqli_query($conn,$q);
if(mysqli_query($conn, $q))
{
echo ("<script LANGUAGE='JavaScript'>
window.alert('Savings Succesfully Updated!');
window.location.href='student_savings.php';
</script>");
}
else {
echo "<script>alert('Savings Failed to Update!')</script>";
}
}
?>
</body>
</html>