Must Fill The Required Fields
Posted: Tue Dec 09, 2008 2:00 pm
i have a simple php feedback form with the following fields
name :: email :: message
my form is very simple that if anyone click on submit it generates the message that "your message has been sent successfully".
i want to make my fields required.
anyone can submit my form without writing anythings in field like no name in name field no email address in mail address or no message in message box.
but i want if anyone submit my form in blank format than it should generates an error that you must fill the required field.
here is my form code.
name :: email :: message
my form is very simple that if anyone click on submit it generates the message that "your message has been sent successfully".
i want to make my fields required.
anyone can submit my form without writing anythings in field like no name in name field no email address in mail address or no message in message box.
but i want if anyone submit my form in blank format than it should generates an error that you must fill the required field.
here is my form code.
Code: Select all
<?php if( isset($submit) ) {
$subject = "Message From Your Website";
$htmlmessage = "
<div style=\"border:1px solid #cccccc; width:80%; padding:10px;\">
Name: $name<br />
Email: $email<br />
Message:
$message
</div>
";
$headers = "From: Feedback Page <webmaster@gmail.com>\r\n";
$headers .= "Content-Type: text/html;\r\n charset=\"iso-8859-1\"\r\n";
$headers .= "Reply-To: $email\r\n";
mail("example@gmail.com", $subject, $htmlmessage, $headers);
echo "<p> THANKS! Your Message Has Been Sent Successfully.</p>";
} else {
?>
<div style="width:400px; margin:auto; text-align:left;">
<form method="post" action="<?php $_SERVER['file:///C|/DOCUME~1/Capricon/LOCALS~1/Temp/Rar$DI00.875/PHP_SELF'];?>">
<p align="left">Name
<input type="text" name="name" />
</p>
<p align="left">Email
<input type="text" name="email" />
</p>
<p align="left">Message</p>
<p align="left">
<textarea name="message" cols="50" rows="10" ></textarea>
</p>
<p>
<label>
<div align="left">
<input type="reset" name="Reset" id="button" value="Reset" />
<input type="submit" value="Send" name="submit" />
</label>
<div align="left"></div>
</form>
<?php
}
?>