$_POST
Posted by: azmantek (---.houston.res.rr.com)
Date: December 30, 2005 05:24AM

WAMP 1.6 installed. I'm using a html form and .php to get user input. However, when I use $_POST, it doesn't work.

On another box without WAMP, $_POST works.

Please help. Thanks

Re: $_POST
Posted by: Reilly Miller (---.dsl.snfc21.pacbell.net)
Date: December 30, 2005 09:19PM

could u give us some of the code? my guess is there is a semi-colon or some such missing. had plenty of these errors, some taking forever to fix, but having someone else look at it usually helps a lot.

Re: $_POST
Posted by: azmantek (---.houston.res.rr.com)
Date: December 31, 2005 05:04AM

Dear Reilly Miller,

Here's the content of calculate_form.html and calculate.php


calculate_form.html

<HTML>
<HEAD>
<TITLE>Calculation Form</TITLE>
</HEAD>
<BODY>
<FORM METHOD="post" ACTION="calculate.php">
<P>Value 1: <INPUT TYPE="text" NAME="val1" SIZE=10></P>
<P>Value 2: <INPUT TYPE="text" NAME="val2" SIZE=10></P>
<P>Calculation:<br>
<INPUT TYPE="radio" NAME="calc" VALUE="add"> add<br>
<INPUT TYPE="radio" NAME="calc" VALUE="subtract"> subtract<br>
<INPUT TYPE="radio" NAME="calc" VALUE="multiply"> multiply<br>
<INPUT TYPE="radio" NAME="calc" VALUE="divide"> divide</P>
<P><INPUT TYPE="submit" NAME="submit" VALUE="Calculate"></P>
</FORM>
</BODY>
</HTML>


caculate.php

<?

if (($_POST[val1] == ""winking smiley || ($_POST[val2] == ""winking smiley || ($_POST[calc] == ""winking smiley) {
header("Location: calculate_form.html"winking smiley;
exit;
}

if ($_POST[calc] == "add"winking smiley {

$result = $_POST[val1] + $_POST[val2];

} else if ($_POST[calc ] == "subtract"winking smiley{

$result = $_POST[val1] - $_POST[val2];

} else if ($_POST[calc ] == "multiply"winking smiley{

$result = $_POST[val1] * $_POST[val2];

} else if ($_POST[calc ] == "divide"winking smiley{

$result = $_POST[val1] / $_POST[val2];

}

?>

<HTML>
<HEAD>
<TITLE>Calculation Result</TITLE>
</HEAD>
<BODY>

<P>The result of the calculation is: <? echo "$result"; ?></p>

</BODY>
</HTML>


I run it from serveral of my hosting sites and it works. It only doesn't work with WAMP. It doesn't work the result at all. All it does is showing "The result of the calculation is" and that's it.

Thank you for your help,

Regards,

Re: $_POST
Posted by: Flex (---.cable.wanadoo.nl)
Date: January 01, 2006 05:32PM

With arrays use:

$_POST['val1']

instead of:

$_POST[val1]


You need to put some ' ' ' ' '

Re: $_POST
Posted by: Flex (---.cable.wanadoo.nl)
Date: January 01, 2006 05:35PM

Or maybe it's <? you use.

Start php with <?php

and switch with <? ?>

Re: $_POST
Posted by: azmantek (---.houston.res.rr.com)
Date: January 01, 2006 06:57PM

Dear Flex,

Thank you very much for your help. Yes, it was the <? ?> that made the program not running. I'm surprised because in all of the PHP books that I've been reading, they said that <? ?> was standard. I followed your instruction by replacing <??> with <?php ?> and it worked smiling smiley.

Thanks again and Happy New Year brother.

Regards,

Re: $_POST
Posted by: Kyrin (---.houston.res.rr.com)
Date: January 02, 2006 03:29PM

Yeah you probably didn't have short tags enabled

Re: $_POST
Posted by: Flex (---.cable.wanadoo.nl)
Date: January 02, 2006 04:21PM

A happy new year to you too :-)

Re: $_POST
Posted by: azmantek (---.houston.res.rr.com)
Date: January 02, 2006 06:17PM

Dear Flex,

Would you please show me how to enable short tags <? ?> ? Thank you very much.

Regards,

Sorry, only registered users may post in this forum.