I want to build a simple server-side validation and I have a problem:
When the user submits the data and it is not correct, I want to keep the correct data into the input(example: if I have two fields, username and email, but only the email is not valid, the username should be saved).
In the following code I tried to create the attribute value only if the variable $validUser
was initialized. Otherwise, I do not want a value attribute. The code is not working.
<input type="text" placeholder="Username" name="username" id="username"
<?php
if ($validUser) echo "value='$validUser'";
?>
/>
What should I do?