Creat simple calcutator using with HTML and PHP
<head>
<style>
.header{
height:500px;
width:450px;
background-color:#CCC;
border: #000 20px solid;
margin-top:50px;
margin-left:200px;
}
</style>
</head>
</br>
<body>
<div class="header">
<form method="post">
<input type="text" name="text" />
<input type="text" name="text1" >
<select name="action">
<option> + </option>
<option> - </option>
<option> * </option>
<option> % </option>
<option> / </option>
</select>
<input type="submit" name="n" value="submit" />
<br />
</form>
<?php
if(isset($_POST['n'])){
$text = $_POST['text'];
$text1 = $_POST['text1'];
$action = $_POST['action'];
if($action =="+"){
echo "answer is:<br>";
echo $text + $text1;
}
if($action =="-"){
echo "answer is:<br>";
echo $text - $text1;
}
if($action =="*"){
echo "answer is:<br>";
echo $text * $text1;
}
if($action =="%"){
echo "answer is:<br>";
echo $text % $text1;
}
if($action =="/"){
echo "answer is:<br>";
echo $text / $text1;
}
}
?>
</div>
</body>
note: you can take two input field and one submit button.
> write all operators
>use the php tags
> print the message
<head>
<style>
.header{
height:500px;
width:450px;
background-color:#CCC;
border: #000 20px solid;
margin-top:50px;
margin-left:200px;
}
</style>
</head>
</br>
<body>
<div class="header">
<form method="post">
<input type="text" name="text" />
<input type="text" name="text1" >
<select name="action">
<option> + </option>
<option> - </option>
<option> * </option>
<option> % </option>
<option> / </option>
</select>
<input type="submit" name="n" value="submit" />
<br />
</form>
<?php
if(isset($_POST['n'])){
$text = $_POST['text'];
$text1 = $_POST['text1'];
$action = $_POST['action'];
if($action =="+"){
echo "answer is:<br>";
echo $text + $text1;
}
if($action =="-"){
echo "answer is:<br>";
echo $text - $text1;
}
if($action =="*"){
echo "answer is:<br>";
echo $text * $text1;
}
if($action =="%"){
echo "answer is:<br>";
echo $text % $text1;
}
if($action =="/"){
echo "answer is:<br>";
echo $text / $text1;
}
}
?>
</div>
</body>
note: you can take two input field and one submit button.
> write all operators
>use the php tags
> print the message
No comments:
Post a Comment