I have a page with a form in which you have to fill in the user field and select an ingredient with select. I have to verify that the user that is entered is in the database. If not, I'll get the following echo and a button to go back:
$usuario=$_POST['usuario'];
if( !( $usuario == "" ) ){
$consulta="SELECT * FROM usuario WHERE usuario = '$usuario'";
$resultado=mysqli_query($con, $consulta);
$con=mysqli_num_rows($resultado);
if($con == 0){
echo"Usuario inexistente. Introduzca un usuario registrado";
}else{
$con==1;
}
echo"
<form action=\"http://localhost/PROYECTO/pedirPlato.php\">
<div class=\"boton\"><input type=\"submit\" value=\"Vuelve\"/></div>
/form>
";
}
The fact is that when I enter a user who is in the database and I also select an ingredient, I have to put a different button to take me to another page. Code:
if (isset($_POST['ingrediente']) && ($con == 1)){
$resultadoConsulta="SELECT apellidos FROM usuario WHERE usuario = '$usuario'";
$sql=mysqli_query($con, $resultadoConsulta);
$fila= mysqli_fetch_assoc($sql);
while ($fila != null){
$fila['apellidos'];
echo "Apellidos: " .$fila['apellidos'];
$fila= mysqli_fetch_assoc($sql);
}
echo"
<form action=\"http://localhost/PROYECTO/pagar.php\">
<div class=\"boton2\"><input type=\"submit\" value=\"Haz el pago\"/></div>
/form>
";
}
The problem I have is that when I add this last bit of code, the two buttons appear, when I would only have to leave the last "Make the payment" and not the one above "Come back". Where should I place the first button so it does not repeat?