Click to See Complete Forum and Search --> : PHP Configuration Issue, I think...


scuba
12-18-2002, 11:51 PM
I think everything is setup properly and it seems to work. However when I try something like passing variables through a form the variables do not pass. For example:

In one file I have:
<tr>
<td>
<form method='POST' action='item.php'>
<table cellpadding=0 cellspacing=5 border=0>
<tr>
<td><font face=verdana size=2>Enter Account ID:</td>
<td align=left><INPUT TYPE='text' name='AccountID' size='6' maxsize='6'></td>
<td><INPUT TYPE='Submit' name='Submit' value='Submit'></td>
</tr>
</table>
</form>
</td>
</tr>

in the item.php file I call this variable like this:
<?

echo("$AccountID");

?>

Nothing displays though. Information is php tags will display, so it processes that much, but I cannot pass variables. The code looks correct so I'm thinking it's a configuration issue. Can anyone at all help me here?

Thanks,
Scuba

dalecosp
12-19-2002, 12:55 AM
Register globals, man, register globals...

It sure looks like it anyway. If you can do this in 'item.php':

<?

echo("$_POST['AccountID']");

?>

and it works, then that's what's up. Most texts and tutorial are still written with register_globals set to "ON", but PHP no longer ships that way. There are lots of workarounds, but it's probably best, if you're getting into php for the 1st time, to learn about the superglobal arrays and start coding with them....

HTH,

scuba
12-20-2002, 01:36 AM
When I try what you mentioned I get:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\Apache Group\Apache2\htdocs\backyardautos\item.php on line 36

not sure if this is a good thing or a bad thing.

Thanks,
Scuba

dalecosp
12-20-2002, 10:19 AM
Originally scribed by scuba:
good thing or a bad thing....
One or the other, surely. Try taking the single quotes from around the array key (in this case the word AccountID) and see if the parse error goes away.

Funny that the handbook says to do it that way, but it doesn't work with the echo statement --- or, maybe it's not so funny. Somebody smarter than me had best tell us how to escape the quotes, or else I should just RTFM, eh?

Or, a genuine kludge:

$var=$_POST['AccountID'];
echo "$var";

;)

scuba
12-20-2002, 02:28 PM
Worked like a charm.

Thank You very much :)

dalecosp
12-22-2002, 04:35 PM
In the words of the immortal PHP master Yoda:

"Welcome you are, mmmm...." ;)