![]() |
VOOZH | about |
PHP can be easily embedded in HTML files, and HTML code can also be written in a PHP file. The key difference between PHP and a client-side language like HTML is that PHP code is executed on the server, while HTML code is directly rendered in the browser. To display errors for invalid input using HTML and PHP, follow this approach:
The following code for "form.php" demonstrates how to handle invalid input in PHP. First, set the name of the input textbox in HTML. All fields are checked for emptiness and then validated for correctness. If all fields are correct, a success message is shown. If the input is invalid, an "Invalid input!!" message is displayed.
The following code uses the above PHP "form.php" code.
Output:
Invalid input!!!Thank you chetan, 123456789 is correct