Jump to content

how to use variables for textbox names


otuatail

Recommended Posts

Hi  I am trying to use variables for then names of password input textbox but can't get my head around this one.

 

first form has

<input type="password" Name="<?=$_SESSION['$key2']?>" value="">

 

Second form has

if($_REQUEST["User"] == ""  || $_REQUEST["<?=$_SESSION["$key2"]?>"] == "")  // Line 13

Dosn't like this line

 

Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/fhlinux145/l/lowther-york.co.uk/user/htdocs/admin/verify.php on line 13

 

Any help on this please.

 

Desmond.

 

 

Link to comment
https://forums.phpfreaks.com/topic/124044-how-to-use-variables-for-textbox-names/
Share on other sites

I'm not too sure but I don't think you should have:

 

<?=$_SESSION["$key2"]?> surrounded by <?= and ?> because you are already in php. That's if it's in html.

 

so that should read:

 

if($_REQUEST["User"] == ""  || $_REQUEST["$_SESSION["$key2"]"] == "")

 

From what I can see now, there is an extra "] which shouldn't be^ there.

 

Replace the line with this and see if it helps:

 

if($_REQUEST["User"] == ""  || $_REQUEST["$_SESSION["$key2"] == "")

 

Hope that helps at least a little bit.

Sorry, what I just said is totally screwed. Maybe ignore what I said and wait for someone who actually knows what they're talking about.

 

I did have an idea though.

 

You could put the second session into a variable.

 

$key2SESSION = $_SESSION["$key2"];

 

then replace the second request with this:

 

$_REQUEST["$key2SESSION"]

 

so now it looks like:

 

if($_REQUEST["User"] == ""  || $_REQUEST["$key2SESSION"] == "")

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.