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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forms and variable passing - IIS 1

Status
Not open for further replies.
Joined
Dec 29, 2003
Messages
4
Location
GB
Hi everyone,
I am a complete novice with PHP and have tried out some tutorials I found at WebMonkey.
I've spent around fifteen hours playing with 3 scripts that use forms to pass variables, but without success.
The error returned is along the lines of :-
"Undefined variable: FName in C:\Inetpub\ on line 15"
using &quot; FName:<input type=&quot;Text&quot; name=&quot;FName&quot;> within the form.
The tutorial appears to suggest that the variable $FName should automatically be assigned the content of the forms textbox upon hitting the &quot;submit&quot; button.
Is this the case?
I have played around and managed to assign the correct values by cycling through the content of $HTTP_POST_VAR, but I feel sure this is not how it should be done!
The original Webmonkey code is similar to the following; the vars being changed to reflect the required input:-
<html>
<body>
<?php
if ($submit) {
// process form
while (list($name, $value) = each($HTTP_POST_VARS)) {
echo &quot;$name = $value<br>\n&quot;;
}
} else{
// display form
?>
<form method=&quot;post&quot; action=&quot;<?php echo $PHP_SELF?>&quot;>
FName:<input type=&quot;Text&quot; name=&quot;FName&quot;><br>
Surname:<input type=&quot;Text&quot; name=&quot;Surname&quot;><br>
Address:<input type=&quot;Text&quot; name=&quot;Address&quot;><br>
PostCode:<input type=&quot;Text&quot; name=&quot;PostCode&quot;><br>
<input type=&quot;Submit&quot; name=&quot;submit&quot; value=&quot;Enter information&quot;>
</form>
<?php
} // end if
?>
</body>
</html>

The page fails with &quot;Undefined variable: submit in C:\inetpub......&quot; on the first pass and fails with a &quot;Page cannot be displayed - incorrect address&quot; when recalled.
With the if/else statement commented out the while loop echos the correct names and values.
Am I correct in thinking this may be a configuration problem specific to IIS?
Any ideas would be much appreciated - but please keep the solutions in a step-by-step format!
I'm really at my wits end with this problem
Sorry its such a long posting!

Many Thanks in advance.....
 
The last versions of PHP doesn't convert automaticaly the form vars in the $var

You should always use:
$_POST[&quot;var&quot;]
instead of
$var

If you see in the manual, $HTTP_POST_VARS is depracated, so you should avoid to use it, cause it can be removed someday from PHP.

The same thing appens with the other $HTTP_*_VARS arrays, you should replace them by the $_* arrays.

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin@anikin-skywalker.com
 
Bah ... i always forget the TGML

where you see $_POST&quot;var&quot; you should see
Code:
$_POST[&quot;var&quot;]




Anikin
Hugo Alexandre Dias
Web-Programmer
anikin@anikin-skywalker.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top