Forum Moderators: coopster

Message Too Old, No Replies

variable as input value with PHP / MySQL

         

socal_local

11:43 pm on Aug 8, 2005 (gmt 0)

10+ Year Member



I created a form page with HTTP Authentication that works with a MySQL backend. In addition to a username and
password, there is a 3rd field tied to each entry. For example:

username: 1111
password: 2222
firstname: John

So, when the user enters the u and p, the name 'John' will show up as an input value in a form that will be submitted.

$sql = "SELECT * FROM login WHERE
username = '$PHP_AUTH_USER' AND
password = '$PHP_AUTH_PW'";

$result = mysql_query( $sql )
or die ( 'Unable to execute query.' );
$s = mysql_fetch_array($result);

THEN

<input name="firstname" type="hidden" value="<? echo("$s[firstname]\n");?>"><? print("$s[firstname]\n");?>

Strange thing is, the admin output page I made to read this works in Firefox, Safari, and Netscape. But, when I submit the form and look at the output page in Internet Explorer....I get a blank page (even though the data shows in the table). When, I changed the value to a non-variable, then it works in IE. So, how do you think I can change this to work with IE since most of our users use this.

coopster

2:40 am on Aug 9, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, socal_local.

I'm not really sure at this point ...? I always use single quotation marks on my associative indexes, and there really is no need for the newlines. Also, is there a closing tag for that <input> element? Perhaps it should be

<input name="firstname" type="hidden" value="<?php print $s['firstname'];?>"><?php print $s['firstname'];?> />

phpmattk

5:06 am on Aug 9, 2005 (gmt 0)

10+ Year Member



echo doesn't like array['index'] when using double quotes either. you could do:

echo "<input name=" . $array['index'] . " value=".$array['index']."></form>";

and that'd probably help too

phpmattk

5:07 am on Aug 9, 2005 (gmt 0)

10+ Year Member



I guess I should have completely read the moderators post, sorry, he already said that basically

socal_local

3:50 pm on Aug 9, 2005 (gmt 0)

10+ Year Member



thanks....your suggestion worked.