How can I make PHP print an error inline instead of changing the entire page?
I'd like it to target #errors
and fill that instead of changing everything.
The code I'm currently using is die ("Incorrect username or password.");
I'm very new to PHP so sorry if this is a pretty easy thing to do.
There are 2 ways of doing it.
A real inline method is not entirely PHP-based, as it cannot be used without JavaScript and AJAX calls.
Note the irritating disadvantage of this method: you will need to re-check every field again upon receiving form data finally.
Another one will reload your page but it will be the same page with all the form fields, entered data and also freshly generated error messages. This is called POST/Redirect/GET pattern
here is a short example
while in the form.tpl.php file you have your form fields, entered values and conditional output of error messages
Put the error in a variable where you do your logic and print its contents in #errors. For example:
And in the HTML