Jump to content

Form Error Messages


Dysan

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.