In this tutorial, I will show you how a program using PHP to ask the user to give six numbers and then
the program will compute the sum of six numbers given by the user.
I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price. My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com
If you like this video please LIKE, SHARE, and SUBSCRIBE to my channel.
Thank you very much for your support.
Program Listing
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Addition of Six Numbers in PHP</title>
<style>
body {
background: #f1f1f1;
font-family: arial;
size : 16px;
}
form {
background-color: rgba(0, 0, 0, 0.7);
color: #000;
padding: 50px;
position: absolute;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
left: 50%;
top: 50%;
}
.row {
display: block;
font-size: 0;
margin-bottom: 18px;
}
h1 {
color: #fefefe;
text-align: center;
margin: 0 0 40px 0;
}
.row label {
width: 180px;
color: #fefefe;
text-transform: uppercase;
padding-left: 0!important;
}
.row input,
.row textarea {
background-color: #fefefe;
width: 280px;
color: #000000;
}
.row textarea {
resize: none;
}
.row label,
.row input,
.row textarea {
vertical-align: top;
display: inline-block;
border: 0;
margin: 0;
padding: 15px;
font-size: 15px;
}
form button {
background-color: #16222A;
width: 250px;
display: inline-block;
border: 0;
padding: 15px;
color: #fefefe;
font-size: 15px;
text-transform: uppercase;
cursor: pointer;
}
form #btnClear {
background-color: #486980;
}
input:focus,
select:focus,
textarea:focus,
button:focus {
outline: none;
}
</style>
</head>
<body>
<?php
error_reporting(0);
$num1 = $_POST['txtFirstNum'];
$num2 = $_POST['txtSecondNum'];
$num3 = $_POST['txtThirdNum'];
$num4 = $_POST['txtFourthNum'];
$num5 = $_POST['txtFifthNum'];
$num6 = $_POST['txtSixthNum'];
$result = $_POST['txtResult'];
if(isset($_POST['submit'])) {
$result = ($num1+$num2+$num3+$num4+$num4+$num5+$num6);
}
if(isset($_POST['clear'])) {
$num1 = "";
$num2 = "";
$num3 = "";
$num4 = "";
$num5 = "";
$num6 = "";
$result="";
}
?>
<form action="" method="post">
<h1>Addition of Six Numbers in PHP</h1>
<div class="row">
<label for="txtFirstNum">Give First Number</label>
<input type="text" name="txtFirstNum" id="txtFirstNum"
value="<?php echo $num1; ?>" autofocus>>
</div>
<div class="row">
<label for="txtSecondNum">Give Second Number</label>
<input type="text" name="txtSecondNum" id="txtSecondNum"
value="<?php echo $num2; ?>">>
</div>
<div class="row">
<label for="txtThirdNum">Give Third Number</label>
<input type="text" name="txtThirdNum" id="txtThirdNum"
value="<?php echo $num3; ?>">>
</div>
<div class="row">
<label for="txtFourthNum">Give Fourth Number</label>
<input type="text" name="txtFourthNum" id="txtFourthNum"
value="<?php echo $num4; ?>">>
</div>
<div class="row">
<label for="txtFifthNum">Give Fifth Number</label>
<input type="text" name="txtFifthNum" id="txtFifthNum"
value="<?php echo $num5; ?>">
</div>
<div class="row">
<label for="txtSixthNum">Give Sixth Number</label>
<input type="text" name="txtSixthNum" id="txtSixthNum"
value="<?php echo $num6; ?>">
</div>
<div class="row">
<label for="txtSixthNum">The Result</label>
<input type="text" name="txtResult" id="txtResult"
value="<?php echo $result; ?>">
</div>
<div classs="row">
<button type="submit" name="submit"
id="btnCompute">Compute</button>
<button type="submit" name="clear"
id="btnClear">Clear</button>
</div>
</form>
</body>
</html>
No comments:
Post a Comment