So this is for a project for uni. I'm trying to create a form with a username and password and when you click on the connect button, it's supposed to pop up a window alert but it won't work because of my function "myAlert()". I know the if is wrong but i can't figure it out, I'm using my professor's instructions.
<?php
$name=$password="";
if ($_SERVER["REQUEST_METHOD"] == "POST") { 
    $name = test_input($_POST["name"]);
    $password = test_input($_POST["password"]); 
}
function test_input($data) {
    $data = trim($data);
    $data = stripslashes($data); 
    $data = htmlspecialchars($data); 
    return $data;
   } 
   ?>
    <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div class="container">
<div class="text">
Κωδικός Υπαλλήλου: <br> <input type="text" name="name">
 <br><br> 
Κωδικός: <br> <input type="text" name="password"> 
<br><br>
<button class="connect" onclick="myAlert()">Σύνδεση</button> 
<script> 
function myAlert() {
 if (empty($_POST["name"])) && (empty($_POST["password"])) { 
alert("Δεν συμπληρώσατε τους κωδικούς"); 
} else { 
alert("Επιτυχής σύνδεση"); } 
} 
</script> 
</div> 
</form>
How can I receive the information from the form and depending on the answer, pop up a different message? Do i have to rewrite it?
