Page 1 of 1
Variable and field woes
Posted: Fri Feb 11, 2005 6:59 am
by mikebr
I have a page that has a username field created using the following code:
Code: Select all
<input name="userName" value="<?php echo $userName; ?>" size=22 maxlength=40>
I have <?php extract($_POST); ?> at the top of this same page, now if I place some text in the field, say 'John' and I submit the form "action is back to itself" the field then has the value "<?php echo John; ?>", why would this be? I am testing locally "OSX". I set a couple of bits of text such as
Code: Select all
<?php
if ($un) {
print "$un";
} else {
print "<font color=RED>$un</font>";
}
?>
The $un value prints as expected so php seems must be getting parsed.
I haven't had this problem before so I am totally puzzeled on this.
Posted: Fri Feb 11, 2005 7:06 am
by djot
-
Hi,
Your input field is named userName.
Your testing part prints out $un, not $userName.
(show more code please)
djot
-
Posted: Fri Feb 11, 2005 7:21 am
by mikebr
Your input field is named userName.
Your testing part prints out $un, not $userName.
That's right, I was only demonstrating that php is getting parsed, $un has nothing to do with the $userName variable.
(show more code please)
That's fairly much it apart from the html.
The form action is: (Just back to the same form that contains the $userName field)
Code: Select all
<form action="login.php" method=post name="theForm">
The full line that contains userName is:
Code: Select all
<p><input name="userName" value="<?php echo $userName; ?>" size=22 maxlength=40></p></td>
Thanks
Oh, and the form is called login.php
Posted: Fri Feb 11, 2005 10:48 am
by feyd
it has the same data, because you asked php to print out $userName, which is what that field submits. I don't see how this is being misunderstood.

Posted: Fri Feb 11, 2005 1:20 pm
by mikebr
Humm... I removed the code and field then redid them again and now the <?php echo ; ?> does not appear, so that side seems to be sorted.
Unfortunately the variables do not seem to get passed on, or rather they do but.... I will explain:
I have added an include to the top of the login.php page;
Code: Select all
if(phpversion() >= "4.2.0") {
extract($_POST);
extract($_GET);
}
echo "UN=$userName<br />PW = $userPassword<br />"; // E1
include ($pathї'path_to_public_folder'] . $phpfolderї'phpfolder'] . "/inc.login.php");
echo "UN=$userName<br />PW = $userPassword<br />"; // E3
In this inc.login.php script I have placed the following:
Code: Select all
<?php
echo "UN=$userName<br />PW = $userPassword"; // E2
?>
Now the echos in E1 & E3 print out the values but E2 in the inc.login.php script shows these values as being empty (UN= PW= ), what gives here?, shurly the variable values in that script should be as they are set and not empty?
Thanks
Posted: Fri Feb 11, 2005 1:44 pm
by feyd
sounds like you have some odd settings...
Posted: Fri Feb 11, 2005 1:50 pm
by mikebr
Yes, I guess so.
I loaded these files up to a server and checked them there and they seem to work on that server, so I thought the problem must be with my 'local' ini or config file but on checking another site I have locally that all seems to work, it is a functional database site with includes so if it works then I wonder why the new site does not.
Totally puzzeled