Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

236
Vistas
How to get if-loop to start once conditions are met, without a submit button

I'd like to execute an if-loop where the values within the two fields are compared to the table bestilling within the connected database and then, if there are values within the database that are the same as the ones within the field, will the submit button at the bottom be enabled. However I'm not sure how to get the if-loop to start once the two fields are filled out, help?

<li>Hva er deres Kundenummer?
<input type="text" name="KundeID"> </li>
<li>Hva er deres Passord?
<input type="text" name="password"> </li><br>
<?php
$tjener = "localhost";
$brukernavn = "root";
$passord = "";
$database = "gyldentag takeaway";

$kobling = new mysqli($tjener, $brukernavn, $passord, $database);

function login ($KundeID, $password) {
$result = mysqli_query($con, "SELECT * FROM kunder WHERE KundeID='$KundeID' AND password='$password'");
while($row = mysqli_fetch_array($result)) {
    $success = true;
}
if($success == true) {
    echo 'document.getElementById("Button").disabled = false;';
} else {
    echo '<div class="alert alert-danger">Brukernavn eller Passord er ukorrekt venligst prøv igjen</div>';
}
}
?>
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can't do that like that. It's not possible.

PHP code is processed even before the page is sent to your browser. That means once you have a page visible in front of you, PHP has already shut down.

If you need your page to talk to PHP code on the server, you'll have to look at AJAX requests. With those, you can send requests to the server and respond the the result. That way, you can absolutely do what you want.

You'll need to send the input to the server every time it is changed (onchange) and let the server give you a boolean result. Once you have received a true result, you're done ;)

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda