-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTipCalculator.php
More file actions
75 lines (49 loc) · 1.9 KB
/
TipCalculator.php
File metadata and controls
75 lines (49 loc) · 1.9 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
<!DOCTYPE html>
<html>
<head>
<link type='text/css' rel='stylesheet' href='style.css'/>
<title>Tip Calculator</title>
</head>
<body>
<?php
$title = "Tip Calculator";
echo $title;
?>
<br>
<!-- <form action="tipcalculator.php" method="post">
Tip Percentage <input type = "radio" name="r" value= .18>18%
<input type="radio" name ="r" value=.20>20%
<input type="radio" name = "r" value = .25>25%
<br>
<input type ="submit" name="submit" value="Load Tip">
</form> -->
<br>
<?php
$username ="0.00";
$c = 0;
// echo $_POST["r"];
if(isset($_POST['Submit1'])){
$username = $_POST['username'];
print "TIP: ";
print "$";
print $username * $_POST['r'];
print " ";
print "TOTAL: ";
print "$";
print ($username * $_POST['r']) + $username;
}
?>
<br>
<FORM NAME ="form1" METHOD ="post" ACTION ="tipcalculator.php">
<!-- <input type = "radio" name="r1" value= .18>18%
<input type="radio" name ="r2" value=.20>20%
<input type="radio" name = "r3" value = .25>25% -->
<input type = "radio" name="r" <?php if (isset($r) && $r== .18) echo "checked";?> value= .18> 18%
<input type = "radio" name="r" <?php if (isset($r) && $r== .20) echo "checked";?> value= .20> 20%
<input type = "radio" name="r" <?php if (isset($r) && $r== .25) echo "checked";?> value= .25> 25%
<INPUT TYPE = 'TEXT' Name ='username' value="<?PHP print $username ; ?>">
<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Calculate Tip">
</FORM>
<br>
</body>
</html>