Re: Re: incorrect value from form

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Aziz,


> Try removing the spaces between value = "a" -> value="a". For some odd
> reason chrome translates that for me (on windows) to:
> <option value ="&nbsp;&quot;a&quot;">I’m a regular customer</option>
> Also insure that your files are all utf8 encoded.


Good eye!! That got me working.

The table now reads:

 <td>How did you find Bob’s?</td>
            <td><select name="find">
                <option value="a">I’m a regular customer</option>
                <option value="b">TV advertising</option>
                <option value="c">Phone directory</option>
                <option value="d">Word of mouth</option>
            </select>
            </td>

And the script now outputs this:

This is what's in the $find variable: a

Regular customer.

Thanks again to everyone who contributed to this thread! Especially to Ted
and his excellent PHP web tutorials. They're all great!

Once again Merry Christmas to all!

Thanks

Tim

On Wed, Dec 24, 2014 at 12:26 PM, Aziz Saleh <azizsaleh@xxxxxxxxx> wrote:

>
>
> On Wed, Dec 24, 2014 at 12:21 PM, Tim Dunphy <bluethundr@xxxxxxxxx> wrote:
>
>> Hey guys,
>>
>> Thanks for your response. Thanks also to Ted for posting that tutorial.
>> The
>> tutorial was good, but I'm still having a hard time figuring out why the
>> $find variable doesn't have the value specified in the "value" tag.
>> Because
>> it looks like the value tag in Ted's example works correctly!
>>
>> For example if I have this option selected:
>>
>>   <option value = "a">I’m a regular customer</option>
>>
>> The contents of $find on the php page are "I'm a regular customer" and not
>> the value which should be "a". And that just strikes me as odd!
>>
>> And if I select option a the output on the web page is the following:
>>
>> This is what's in the $find variable: I’m a regular customer
>>
>> We do not know how this customer found us.
>>
>> I thought I enclosed both the orderform.html and processorder.php files in
>> the original email. But I guess I must not have attached one of them.
>>
>> Just so I don't screw that up again, here's the two files inline in the
>> email! :)
>>
>> Neither of them is that long, so I hope no one minds.
>>
>> <!doctype html>
>>
>> <html lang="en-us">
>>
>> <head>
>>
>>     <meta charset="utf-8">
>>
>>     <title>Order Form</title>
>>
>> </head>
>>
>> <body>
>>
>> <form action="processorder.php" method="post">
>>
>>     <table border="0">
>>
>>         <tr bgcolor="#cccccc">
>>
>>             <td width="150">Item</td>
>>
>>             <td width="15">Quantity</td>
>>
>>         </tr>
>>
>>         <tr>
>>
>>             <td>Tires</td>
>>
>>             <td align="center"> <input type="text" name="tireqty" size="3"
>> maxlength="3" /></td>
>>
>>         <tr>
>>
>>         <td>Oil</td>
>>
>>         <td align="center"><input type="text" name="oilqty" size="3"
>> maxlength="3" /></td>
>>
>>         </tr>
>>
>>         <tr>
>>
>>             <td>Spark Plugs</td>
>>
>>             <td align="center"><input type="text" name="sparkqty" size="3"
>> maxlength="3" /></td>
>>
>>         </tr>
>>
>>         <tr>
>>
>>             <td colspan="2" align="center"><input type="submit"
>> value="Submit Order" /></td>
>>
>>         </tr>
>>
>>         <tr>
>>
>>             <td>How did you find Bob’s?</td>
>>
>>             <td><select name="find">
>>
>>                 <option value = "a">I’m a regular customer</option>
>>
>>                 <option value = "b">TV advertising</option>
>>
>>                 <option value = "c">Phone directory</option>
>>
>>                 <option value = "d">Word of mouth</option>
>>
>>             </select>
>>
>>             </td>
>>
>>         </tr>
>>
>>     </table>
>>
>> </form>
>>
>> </body>
>> And here is the processorder.php script:
>>
>> tml>
>> <head>
>>     <title>Bob's Auto Parts - Order Results</title>
>> </head>
>> <body>
>> <h1>Bob's Auto Parts</h1>
>> <h2>Order Results</h2>
>> <?php
>> // create short variable names
>> $tireqty  = $_POST['tireqty'];
>> $oilqty   = $_POST['oilqty'];
>> $sparkqty = $_POST['sparkqty'];
>> $find     = $_POST['find'];
>>
>>
>> echo '<p>Your order is as follows:</p>';
>> if ($tireqty ==0) {
>>     echo "You did not order anything on the previous page!<br />";
>> } else {
>>     if ($tireqty > 0)
>>         echo $tireqty." tires<br />";
>>     if ($oilqty > 0)
>>         echo $oilqty." bottles of oil<br />";
>>     if ($sparkqty > 0)
>>         echo $sparkqty." spark plugs<br />";
>> }
>>
>> echo "<br /><br />";
>>
>> $totalqty = 0;
>> $totalqty = $tireqty + $oilqty + $sparkqty;
>> echo "Items ordered: " . $totalqty. "<br ./>";
>>
>> define('TIREPRICE', 100);
>> define('OILPRICE', 10);
>> define('SPARKPRICE', 4);
>>
>> $totalamount = $tireqty * TIREPRICE
>>    + $oilqty * OILPRICE
>>    + $sparkqty * SPARKPRICE;
>>
>> echo "Subtotal:    $".number_format($totalamount,2)."<br />";
>> $taxrate = 0.10;
>> $totalamount = $totalamount * (1+ $taxrate);
>> echo "Total     Including     Tax:
>> $".number_format($totalamount, 2)."<br />";
>>
>> /*echo "<p>this is the $_POST[find] variable: " . var_dump($_POST['find'])
>> . "</p>";
>> echo "<p>this is the \"find\" variable: " . var_dump($find) . "</p>";*/
>>
>> echo  '<p>This is what\'s in the $find variable: ' . $find . '</p>';
>>
>> /*if ($find == "I’m a regular customer") {
>>     echo "<p>Regular customer.</p>";
>> } elseif ($find == "TV advertising") {
>>     echo "<p>Customer referred by TV advert";
>> } elseif ($find == "Phone directory") {
>>     echo "<p>Customer referred by phone directory</p>";
>>  } elseif ($find == "Word of mouth") {
>>     echo "<p>Customer referred by word of mount</p>";
>> } else {
>>     echo "<p>We do not know how this customer found us.</p>";
>> }*/
>>
>> if ($find == "a") {
>>     echo "<p>Regular customer.</p>";
>> } elseif ($find == "b") {
>>     echo "<p>Customer referred by TV advert";
>> } elseif ($find == "c") {
>>     echo "<p>Customer referred by phone directory</p>";
>> } elseif ($find == "d") {
>>     echo "<p>Customer referred by word of mount</p>";
>> } else {
>>     echo "<p>We do not know how this customer found us.</p>";
>> }
>>
>> ?>
>> </body>
>> </html>
>>
>> Furthermore, the script I'm working with is actually hanging out on the
>> Internet right here:
>>
>> http://php.lyricgem.com/orderform.html
>>
>> That's in case you want to see it in action. That's just my hobby dev
>> instance on the amazon free tier! Notthing there needs to be secure that
>> isn't already protected by the firewall!
>>
>> Thanks and Merry Christmas to all!
>> Tim
>>
>>
>> On Wed, Dec 24, 2014 at 11:41 AM, Jim Giner <jim.giner@xxxxxxxxxxxxxxxxxx
>> >
>> wrote:
>>
>> > The code as posted works just fine for me.  Must be something you are
>> not
>> > showing us that is affecting your html.  Have you looked at the source
>> code
>> > in the browser window to see if it appears correctly?
>> >
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> >
>>
>>
>> --
>> GPG me!!
>>
>> gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
>>
>
>
> Try removing the spaces between value = "a" -> value="a". For some odd
> reason chrome translates that for me (on windows) to:
>
> <option value ="&nbsp;&quot;a&quot;">I’m a regular customer</option>
>
> Also insure that your files are all utf8 encoded.
>



-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux