Hmm I really don't get it but my code somehow returns an empty string? Here's the code:
<form id="form1" name="form1" method="post" action="">
<p>
</p>
<p>
<select name="lbox" id="listbox">
<?php
$sqlString = "SELECT * FROM admintbl";
$con = mysql_connect("localhost","root","");
mysql_select_db("dbmain", $con);
$dat = mysql_query($sqlString);
$user = "";
while ($row_i = mysql_fetch_assoc($dat)) {
if ($user !== $row_i['user']) {
$user = "";
}
if ($user == "") {
$user = $row_i['user'];
?>
<option value=<?php $user ?>><?php echo $user ?></option>";
<?php
}
?>
<?php }
echo mysql_error();
mysql_close($con);
?>
</select>
<input type="submit" id="submit" name="submit"/>
</p>
</form>
And here is where I am trying to get the value from the listbox but is empty.
<?php
if (isset($_POST['submit'])) {
$check = $_POST['lbox'];
echo "<script> alert('$check')</script>";
if ($check == "mac") {
echo "<script> alert('this message')</script>";
}
}
?>
Any idea on what to do or where am I wrong? I just cant really get it why. The "mac" is set to be one of the values in the option in listbox. Thanks and more power to you guys!