You are here: Re: Newbie needs help with simple error from textbook « PHP Programming Language « IT news, forums, messages
Re: Newbie needs help with simple error from textbook

Posted by Harry Haller on 10/10/05 06:25

On Sun, 09 Oct 2005 22:45:58 +0100, Philip Ronan
<invalid@invalid.invalid> wrote:

>"Harry Haller" wrote:
>
>(snip)
>> What has gone wrong here and how can I fix it?
>>
>> <?php
>>
>> while (list($key, $value) = each($HTTP_POST_VARS))
>> {
>> echo "$key = $value<BR>";
>> }
>> echo "<HR>";
>>
>(snip)
>> echo "<INPUT TYPE='HIDDEN' NAME='Course1' VALUE='$ListBox1'>";
>
>Am I right in assuming $ListBox1 is a variable posted from the last form? If
>so, you should include some code to set this variable in the PHP code. At
>the moment you're just listing the POST vars without setting anything.
>
>Try inserting another line into your while() loop like this:
>
> {
> echo "$key = $value<BR>";
> $key = $value;
> }

OK ppl, I figured it out. PHP5 default settings in php.ini are
incompatible with PHP4.

http://www.ineasysteps.com/updates/PHP_Form_Variables.pdf

I modified my code to use the $_POST[] array.

<HTML>
<HEAD><TITLE>Welcome to Charlie's dessert selection</TITLE></HEAD>
<BODY>
<?php

$Desserts=array("Apple Pie ($3)","Pancakes ($3)","Ice Cream ($2)");

echo "<FORM METHOD='POST' ACTION='bill.php'>";
echo "Which of the following would you like as a dessert?";
echo "<SELECT NAME='ListBox2'>";
echo "<OPTION SELECTED VALUE=''>Select...</OPTION>";
echo "<OPTION>$Desserts[0]</OPTION>";
echo "<OPTION>$Desserts[1]</OPTION>";
echo "<OPTION>$Desserts[2]</OPTION>";

echo "</SELECT><BR><BR>";
echo "<INPUT TYPE='HIDDEN' NAME='Course1' VALUE='" .
$_POST["ListBox1"] . "'>";
echo "<INPUT TYPE='SUBMIT'>";
echo "</FORM>";
?>
</BODY>
</HTML>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация