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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.