Dysan Posted April 22, 2008 Share Posted April 22, 2008 Hi, I have the following HTML form Using PHP, how do I display error messages above the form, upon the user not entering a data? Also, if the user does enter valid data, how do I submit the form? <html> <body> <form action="insert.php" method="post"> Firstname: <input type="text" name="firstname" /> Lastname: <input type="text" name="lastname" /> Age: <input type="text" name="age" /> <input type="submit" /> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/102358-form-error-messages/ Share on other sites More sharing options...
DeanWhitehouse Posted April 22, 2008 Share Posted April 22, 2008 if you want to make sure all fields are filled in put. $firstname = $_POST["firstname"] $lastname = $_POST["lastname"] $age = $_POST["age"] if($firstname && $lastname && $age) {echo "all fields are filled in";} else { echo "please fill in all fields"; } this should send you in the right direction, this goes in the submit form. to echo onto the page add require_once 'page_name.php'; in the else curly brackets Quote Link to comment https://forums.phpfreaks.com/topic/102358-form-error-messages/#findComment-524119 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.