PHP Variables

ScottyB

New Member
Messages
5
Reaction score
0
Points
0
I am at the point where I don't know if it's just me, or the PHP configuration. I can not get variables to pass between pages, for example:

This code:
<?
echo $EnteredText;

print "<form method=\"POST\" action=\"$PHP_SELF\">
<input type=\"text\" name=\"EnteredText\" size=\"20\">
<input type=\"submit\" value=\"Submit\">
</form>";
?>
is currently in a php file at http://scottyb.pcriot.com/phptest.php. When something is entered in the form field and submit is pressed the entered text is placed in the $EnteredText variable and printed above the form when the page reloads. Why does this not work on this host?

I've been upgraded to version 2 and my request for PHP version 3 was denied. I know that this code should work sinse I have a working copy at my old host that I'm trying to leave (http://nexzign.com/phptest.php).

What is the problem I'n running into here????
 

eminemix

Member
Messages
350
Reaction score
0
Points
16
Here is the code with some changes, if you have any questions just ask. It works !

Code:
<?
echo $_POST['EnteredText'];

echo "<form method=\"POST\" action=\"{$_SERVER['PHP_SELF']}\">
<input type=\"text\" name=\"EnteredText\" size=\"20\">
<input type=\"submit\" value=\"Submit\">
</form>";
?>

http://eminemix.x10hosting.com/tmp/f.php
 

Attachments

  • working.txt
    210 bytes · Views: 45
Last edited:

ScottyB

New Member
Messages
5
Reaction score
0
Points
0
Hummm....screwy. I see that it works on your account, but still does not work on mine. I copied and pasted it right in there and gave it a try and....nothing. i also wonder why you have to refrence the fariavle through POST and all that extra stuff.....
 
Last edited:

easykey

New Member
Messages
45
Reaction score
0
Points
0
I suppose because register globals was on in your old host? Works on mine to... You could try \"phptest.php\" instead of \"{$_SERVER['PHP_SELF']}\"
 
Last edited:

ScottyB

New Member
Messages
5
Reaction score
0
Points
0
The issue is that variables do not pass from one page to the next.
 

eminemix

Member
Messages
350
Reaction score
0
Points
16
It should work on your account.
Give me a link to the new script.
 

ScottyB

New Member
Messages
5
Reaction score
0
Points
0
it's at the same url, I just edited the script by pasting in you code.

Grrrr.....now it is working.

What I figured out is that I'm going to have to add a section of code at the beginning of each pahe that converts variables from the $_GET['Blah'] or $_POST['Blah'] to just $Blah so that the rest of my code will work....
 
Last edited:

eminemix

Member
Messages
350
Reaction score
0
Points
16
I don't think that is necessary. You could use $_POST['foo'] for the rest of the code, it will work.
Or you can
$foo=$_POST['foo'];
and use $foo for the rest of the script.
 

ScottyB

New Member
Messages
5
Reaction score
0
Points
0
Yeah, that's what I'm going to do, have a seciton where all the variables get converted like that. I already wrote all the code years ago, I'm just trying to me the site over here.
 
Top