In this article, I would like to share with you guys a simple calculator written in PHP as our programming language.
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 I also accepting computer repair, networking and Arduino Project development at a very affordable price.
My personal website is http://www.jakerpomperada.com
Program Listing
index.php
<html>
<head>
<title>Calculator in PHP<title>
</head>
<script language="javascript">
function validate_form()
{
var num1 = document.entryform.num1;
var num2 = document.entryform.num2;
if(num1.value==""||num1.value==null)
{
alert("Please specify value on first box");
num1.focus();
return false;
}
else if(num2.value==""||num2.value==null)
{
alert("Please specify value on second box");
num2.focus();
reutrn false;
}
}
</script>
<body>
<form method="post" onSubmit="return validate_form(this)" name="entryform">
<fieldset>
<legend>A simple calculator in PHP</legend>
<input type="text" name="num1" value="<?php echo $_REQUEST['num1']?>">
<select name="opt">
<option value="+">+
<option value="-">-
<option value="*">*
<option value="/">/
</select>
<input type="text" name="num2" value="<?php echo $_REQUEST['num2']?>"><br>
<input type="submit" name="submit" value="Calculate">
<br>
<span id="result">
Result is
<strong>
<?php
if($_REQUEST['opt']=="+"){
echo $_REQUEST['num1']+$_REQUEST['num2'];
}
else if($_REQUEST['opt']=="-"){
echo $_REQUEST['num1']-$_REQUEST['num2'];
}
else if($_REQUEST['opt']=="/"){
echo $_REQUEST['num1']/$_REQUEST['num2'];
}
else if($_REQUEST['opt']=="*"){
echo $_REQUEST['num1']*$_REQUEST['num2'];
}
?>
</strong>
</span><br>
<span id="navigation"><a href="index.php">Calculate Again</a></span>
</fieldset>
</form>
</body
</html>
No comments:
Post a Comment