variable as input value with PHP / MySQL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff

    #1

    variable as input value with PHP / MySQL

    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_arr ay($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.
  • Tim Roberts

    #2
    Re: variable as input value with PHP / MySQL

    Jeff <swiz310@NOSPAM comcast.net> wrote:[color=blue]
    >...
    >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_arr ay($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.[/color]

    There's nothing wrong with this code. You need to show us the rest of the
    HTML (including the <form> header) and the PHP code that creates the
    response. The problem is almost certainly much later than what you've
    shown us here
    --
    - Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.

    Comment

    • Jeff

      #3
      Re: variable as input value with PHP / MySQL

      Tim Roberts wrote[color=blue]
      >
      > There's nothing wrong with this code. You need to show us the rest of the
      > HTML (including the <form> header) and the PHP code that creates the
      > response. The problem is almost certainly much later than what you've
      > shown us here[/color]

      I found the solution. Thanks though.
      I changed:

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

      TO:

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

      Comment

      Working...