Jump to content

Calculator Script not executing


Far Cry

Recommended Posts

Hey there, I recently started working on a PHP calculator, I tryed testing it out and the script is not executing... *NOTE* I found the error, I forgot to assign values to the options, all is good now

 

<?php
/*
Script Created by: Far Cry
Started: August 20th, 2010 10:51 PM PST
Completed
*/

$title = "Calculator";

$form = "<form action='calculator.php' method='POST'>
<table> 
    <tr>
    <td><input name='firstnumber' type='text'></td>
</tr>

<tr>
   <td><input name='secondnumber' type='text'></td>
</tr>

<tr>
   <td><select name='operation'>
       <option name='multiply'>*</option>
	   </select></td>
</tr>

<tr>
<td><input name='submitbtn' type='submit' value='Calculate!'></td>
</tr>
</table>
</form>";


if ($_POST['submitbtn']){

	$first = ($_POST['firstnumber']);
	$last = ($_POST['secondnumber']);
	$operation = ($_POST['operation']); 
}
if ($operation == 'multiply'){
echo"The answer is " . $first * $last . $form;
}
echo $form;
?>

 

Thanks in advance.

 

Link to comment
https://forums.phpfreaks.com/topic/211377-calculator-script-not-executing/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.