Necesita mostrar el nombre de usuario en el cuadro combinado después de iniciar sesión correctamente en PHP
Frecuentes
Visto 218 equipos
0
i want to show the username after successful login in a combobox.
<?php
$val = $_POST['applicant']?:'';
$sql = "SELECT username FROM `user` where password = '".$_SESSION['password']."'";
$res = mysql_query($sql);
while ($row1 = mysql_fetch_array($res)) {
$selected = ($val == $row1['username'] ? 'selected="selected"' : '');
echo '<option value ="' . $row1['username'] . '" '. $selected .'>' . $row1['username'] . '</option>';
}
?>
1 Respuestas
0
prueba este
$val = "";
if(isset($_POST['applicant']))
{
$val = $_POST['applicant'];
}
$sql = "SELECT username FROM `user` where password = '".$_SESSION['password']."'";
$res = mysql_query($sql);
while ($row1 = mysql_fetch_array($res)) {
$selected = ($val == $row1['username']) ? 'selected="selected"' : '';
echo '<option value ="' . $row1['username'] . '" '. $selected .'>' . $row1['username'] . '</option>';
ACTUALIZACIÓN
actualización para still no result
comentario
you can use trim you post value and check it in table user
en columna username
mannualy that exists in database or not
$val = "";
if(isset($_POST['applicant']))
{
$val = trim($_POST['applicant']);
}
echo $val;
}
Respondido 12 Feb 14, 06:02
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas php combobox or haz tu propia pregunta.
i think issue is not clear. i have a table named "user" that has username and password column. i am loging using this two value. after successfully login i want to insert the username as applicant field in another table. - Basudev