PHP Form in Page Template
-
I have created a new page tempate on my site and added the following code:
<div id="calculator"> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> How much do you pay for your gas?<br /> <input name="gas" id="gas" /> Per Month<br /><br /> How much do you pay for boiler cover?<br /> <input name="cover" id="cover" /> Per Month<br /><br /> <input type="submit" /><br /> </form> Preview:<br /> <?php $gasCost = ($_POST['gas']); $boilerCoverCost = ($_POST['cover']); $gasSaving = $gasCost*0.3; $totalSaving = ($gasCost * 0.3) + $boilerCoverCost; echo "Gas Saving = $gasSaving <br />Boiler Cover = $boilerCoverCost <br />Total Saving = $totalSaving"; ?> </div>
But, when a user enters data into the 2 form fields and clicks submit, they are just redirected to index.php! Please help
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘PHP Form in Page Template’ is closed to new replies.