Forum Moderators: coopster
Say i have a generic HTML form:
<form action="welcome.php" method="get">
First Name: <input type="text" name="firstname" /><br />
Last Name: <input type="text" name="lastname" /><br />
<input type="submit" value="Submit" />
</form>
Then on the php page I have:
<?php
echo( "Welcome, $firstname $lastname!" );
?>
It shows the querys in the url /welcome.php?firstname=*&lastname=*
But All I get is Welcome, ! on Submit.
Anyone have any ideas what I am doing wrong? Thanks.
Parse error: parse error, unexpected '\"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in c:\inetpub\wwwroot\welcome.php on line 7
I even tried it like this:
echo( "Welcome to our Web site, " . $firstname . $lastname . "!" );
Didn't work either.
Also, register_globals = On in my php.ini.
[edited by: RussellC at 5:34 pm (utc) on Oct. 22, 2002]
echo( "Welcome, {$HTTP_GET_VARS['firstname']} {$HTTP_GET_VARS['lastname']}!" );
The {} lets PHP know to interpolate the array reference correctly. using "'" instead of '"' for the array key string avoids any possibility of your string being interpretted as ending at the '['.
If you're using a recent version of PHP, you might want to use $_GET instead of $HTTP_GET_VARS. $HTTP_GET_VARS is deprecated and may be removed in the future.
<added>Jatar_k's last approach ought to work, too.</added>
[edited by: dingman at 5:41 pm (utc) on Oct. 22, 2002]
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in c:\inetpub\wwwroot\welcome.php on line 7
Bingo:
I just make a phpinfo.php file to look at the settings on my php.ini file and it looks like all of the stuff I changed in php.ini didnt really change. It says register_globals = Off and it shows my extensions directory as c:\php4 when it isn't. I have the php.ini file in C:\windows\. Why isnt it seeing my settings changes?