...

View Full Version : help with simple form php code



Extrovertive
07-10-2002, 02:31 AM
<html>
<head>
<title> Testing </title>
</head>
<body>

<h2> The BACKWORD: </h2>
<br>

<?php

if(isset($string))
{
for($i = strlen($string)-1; $i >= 0; $i--)
{
print $string[$i];
}
}
else
{

?>
<FORM METHOD=POST ACTION="<?php echo $PHP_SELF;?>">
Enter a word: <INPUT TYPE="text" NAME="string">
<INPUT TYPE="submit" value="done!">
</FORM>
<?php
}
?>

</body>
</html>



ok, i need help with the above code. im trying to write a simple php script in which it ask a user for a word in the field textbox. then when the user press 'done!', it will output the user's word backword.

for some reason, when i press done! it always show the same "Enter a word" stuff.

Spookster
07-10-2002, 03:53 AM
I just tried it and it worked just fine. :confused:

Extrovertive
07-10-2002, 04:03 AM
weird. testing it offline on my localhost doesnt work. but i when i upload it on my webserver, it works. what's up with that???

boxer_1
07-10-2002, 04:45 AM
Originally posted by Extrovertive
weird. testing it offline on my localhost doesnt work. but i when i upload it on my webserver, it works. what's up with that???

Same here, when I tried testing it on my localhost I got "HTTP 500 - Internal server error".

Edit: Any relevance here?: http://www.microsoft.com/serviceproviders/webhosting/HowTo/P118948.asp

Spookster
07-10-2002, 05:41 AM
I tested it locally on my machine. I am running firepages phpdev on winXP. What are you running?

firepages
07-10-2002, 07:22 AM
try and get used to using the new super_globals arrays
......


<?php

if(isset($_POST[string]))
{
for($i = strlen($_POST[string])-1; $i >= 0; $i--)
{
print $_POST[string][$i];
}
}
else
{

?>

.....


<FORM METHOD=POST ACTION="<?php echo $_SERVER[PHP_SELF];?>">



its a pain but one we are stuck with!

note to be backwards compatible you need to use $HTTP_POST_VARS[string] etc but the superglobals $_POST, $_GET etc should be available from php4.06+

Extrovertive
07-10-2002, 08:42 AM
thanks a lot firepages. do u know where i can find this on the php usermanual?

mordred
07-10-2002, 10:02 AM
http://www.php.net/manual/en/language.variables.predefined.php

Also, the superglobals are available since PHP 4.1.0.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum