Forum Moderators: coopster

Message Too Old, No Replies

Creating a PHP Form

Newbie learning the ropes

         

johnnydequino

3:34 pm on Dec 15, 2003 (gmt 0)

10+ Year Member



I just started created a simple PHP form, and I am trying to learn the ropes. All I would like to do with this form is have a user input a phone number, let's say, and 'POST' it in the body of another PHP webpage. Am I missing something obvious?

<form action="widgets.php" method="POST">
(</font></td><td><font face=arial size=2><input type="text" name="areacode" value="" size=3 maxlength=3></font></td><td><font face=arial size=2>)&nbsp;
</font></td><td><font face=arial size=2><input type="text" name="prefix" value="" size=3 maxlength=3>
</font></td><td><font face=arial size=2>&nbsp;- XXXX
</font></td><td><font face=arial size=2>
&nbsp;<input type="submit" value="Search">
</font></td></tr></form>

PHP Code on widgets.php - the values don't show only 'your area code' and 'your prefix' with out the users input:

Your area code: <?php echo $_POST["areacode"];?><br>
Your Prefix: <?php echo $_POST["prefix"];?>

Hopefully this is a simple, newbie question. =)

jd

coopster

4:00 pm on Dec 15, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The PHP looks OK. Are you sure you don't have something fishy in your HTML? Try trimming the HTML back to some very basics, for example:

<form action="widgets.php" method="post">
<input type="text" name="areacode" value="" size=3 maxlength=3><br>
<input type="text" name="prefix" value="" size=3 maxlength=3><br>
<input type="submit" value="Search">
</form>

Then see if you get anything in your $_POSTed variables. If so, you'll know where to start ;)
BTW, Welcome to the PHP forum!

jatar_k

5:55 pm on Dec 15, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



also check the php version, if it is below 4.1.0 you will need to use $HTTP_POST_VARS instead of $_POST.

You can check your php version by putting

<?php phpinfo [ca.php.net]();?>

in a file, uploading it and viewing it in your browser. It will give you all of the info regarding your php installation.