Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

240
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!