-1

I have a simple dropdown menu which posts the result to itself but when i choose one of the options in the drop down menu it does not echo back the result as expected.

I'm sure i've just missed out something simple but can't spot it. Any ideas? The form posts but does not echo back $user_settings.

<?php
include "functions.php";
connect();

$sql="SELECT user_id, user_realname FROM users ORDER BY user_realname ASC";
    $result=mysql_query($sql);

    while ($row = mysql_fetch_array($result)) {
        $name=$row['user_realname'];
        $options.="<OPTION VALUE=>".$name.'</option>';
        }

if(isset($_POST['submit'])){
    $user_realname = $_POST['username_select'];
    $user_select = mysql_query("SELECT user_id, user_realname FROM users WHERE user_realname = '$user_realname'")
    or die ("Could not get user data");

    while($row = mysql_fetch_array($user_select)){

        $user_settings = $row['user_id'];
        echo $user_settings;
    }
}
?>

<html>
    <head>
        <body>
            <form action="<?php echo $PHP_SELF;?>" method="POST">
                <tr><label>Choose User to Edit</tr>
                <tr><SELECT NAME="username_select"><OPTION VALUE=""></option>User's Name<?php echo $options;?></SELECT></label></tr>
                <tr><input type="submit" value="submit" name="submit"></tr>
            </form>
            <?php echo $user_settings;?>
            <br/>
            <a href="admin.php">Go Back</a>
        </body>
    </head>
</html>
4

1 に答える 1

2

$_SERVER['PHP_SELF']$PHP_SELF の代わりのユーザー

于 2012-08-27T10:13:23.147 に答える