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> 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 Link to comment https://forums.phpfreaks.com/topic/102358-form-error-messages/#findComment-524119 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.