can't pass values to variables
Posted by: newwampuser (202.148.56.---)
Date: November 24, 2006 08:20AM

hi.. I've installed wamp5 . I can access normal php scripts. but if i want to pass
value to a variable of a "php script " from a "form of html file" ...the php file can't
get the value .If i print that value in the php file prints nothing.

the code is similar to


<form method = "get"
action = "hiUser.php">


print "<h3>Hi there, $userName!</h3>";

hiUser.php just prints "Hi there, !"

Should I configure the php.ini file for it ....or should i do??

Options: ReplyQuote
Re: can't pass values to variables
Posted by: CyberSpatium (71.237.217.---)
Date: November 24, 2006 10:20AM

registe globals was disabled by the php development team for security reasons in php version 4.2. wamp uses php 5.2.x. so, now when you use a script php creates super globals for those values. since you used the form method type of get in your from, you can access your variable from the super globals array like this:


so, change your script to:
print "<h3>Hi there, " . $_GET['userName'] . "!</h3>";

if you had used form method = "post" instead, then you would need to change your code to this:
print "<h3>Hi there, " . $_POST['userName'] . "!</h3>";

Info on Register Globals

More info on Super Globals

Using Forms

WAMP English Forum Admin

Options: ReplyQuote

Sorry, only registered users may post in this forum.