I've got something that almost works. It does work when data is entered into the fields. The problem is it also works when the page is loaded.
When the page is loaded, both fields are empty and that means they match. So the echo statement "Passwords match" is displayed on the screen before the user enters any data.
Is there a way to say don't apply the if else statement until the submit button is clicked.
Below is the code I'm using.
Help!
<html>
<head>
<title>No frills regestration form</title>
</head>
<body>
<form action="server_side_validation.php" method="post">
Password:<input type="text" name="psword">
<br>
Reenter Password<input type="text" name="reenter_psword">
<br>
<input type="submit" value="Submit">
</form>
<?php
if ($_POST["psword"] != $_POST["reenter_psword"] )
echo "Passwords don't match.";
else
{
echo "Passwords match";
}
?>
</body>
</head>