Help with assigning a value to a variable based on the selector of a form.

Cant seem to get this to work, echo the $specprice based on what is selected using the form.

FORM:

Price:
Option1 Option2

Script:
$price = $_POST[‘price’];
switch ($_POST[‘type’]) {
case 1:
$specprice = “2.64”;
break;
case 2:
$specprice = “3.07”;
break;
}
echo $price;
echo $specprice;

The following should give you a clue in what you’re doing wrong.

[php]<?php
/* Try to keep most of you php at the top of the page. */
if ( isset($_POST[‘submit’]) && $_POST[‘submit’] === ‘Submit’ ) {
$color = htmlspecialchars($_POST[‘color’]);
echo 'Color is ’ . $color . “\n”;
}
?>

Untitled Document Blue Pink Raspberry

[/php]

Thank you, that is exactly what I needed to see.

Greatly appreciated.

Sponsor our Newsletter | Privacy Policy | Terms of Service