Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FORM ACTION="displayit.php"... Not passing variables. Why?

Status
Not open for further replies.

grwd

Technical User
Jan 20, 2002
20
0
0
US
I have apache 2.0.35, PHP4, ... on a win98 server.

I have an HTML form info.html:

<BODY>
<FORM ACTION=&quot;displayit.php&quot; METHOD=&quot;POST&quot;>
Your first name:<BR>
<INPUT TYPE=&quot;text&quot; NAME=&quot;fname&quot; SIZE=&quot;20&quot; MAXLENGTH=&quot;30&quot;>
Your last name:<BR>
<INPUT TYPE=&quot;text&quot; NAME=&quot;lname&quot; SIZE=&quot;20&quot; MAXLENGTH=&quot;30&quot;>
<INPUT TYPE=&quot;submit&quot; VALUE=&quot;Send it!&quot;>
</FORM>
</BODY>


displayit.php:
<?
/* this script should handle the variables passed from the info.html file */
PRINT &quot;<CENTER>&quot;;
PRINT &quot;$fname&quot;;
PRINT &quot; &quot;;
PRINT &quot;$lname&quot;;
PRINT &quot;</CENTER>&quot;;
?>

Variables: fname and lname seem NOT be being passed from form to displayit.php.

We can't use PHP if we can't get something this simple working.
Please help!
tim@tgm.org
 
Hello,
I guess Apache is processing the .php files in your system.
If this is done correctly,the posibility is that your PHP configuration file (php.ini) has the directive register_globals = off
In PHP 4.X this directive is set to off by default due to security issues.
You will find this file in your C:\Windows folder.
Try using in your displayit.php file this code:

<?php
echo &quot;<CENTER>&quot;;
echo $_POST[&quot;fname&quot;];
echo &quot; &quot;;
echo $_POST[&quot;lname&quot;];
echo &quot;</CENTER>&quot;;
?>

This should work fine.Use the $_POST,$_GET arrays to manipulate data from forms,depending on the form method that you are using.
The echo statement is (in my opinion) better than print.

I hope this helps.

alexfusion
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top