<?php $errors = array(); if (isset($_POST['submit'])){ $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $question = $_POST['question']; if($name == ''){ $errors[] = 'Please enter your name.'; } if($email == ''){ $errors[] = 'Please enter your email.'; } if($phone == ''){ $errors[] = 'Please enter your phone number.'; } if(count($errors) == 0){ //if no errors run this code you enter here. } } ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php if(count($errors) > 0){ echo '<ul>'; foreach($errors as $e){ echo '<li style="color:red;"><b>' . $e . '</b></li>'; } echo '</ul>'; } ?> <form action="" enctype="multipart/form-data" method="post" id="yourform"> <table cellpadding="0" cellspacing="0" border="0" width="500"> <tr> <td width="150" valign="top">Full Name <span class="required">*</span></td> <td valign="top"><input name="name" id="name" type="text" size="25" maxlength="255"></td> </tr> <tr> <td width="150" valign="top">Email <span class="required">*</span></td> <td valign="top"><input name="email" id="email" type="text" size="25" maxlength="255"> </td> </tr> <tr> <td width="150" valign="top">Phone <span class="required">*</span></td> <td valign="top"><input name="phone" id="phone" type="text" size="25" maxlength="255"> </td> </tr> <tr> <td width="150" valign="top">Question <span class="required">*</span></td> <td valign="top"><textarea name="question" cols="25" rows="5"></textarea> </td> </tr> <tr> <td width="150"> </td> <td valign="top"><input name="submit" type="submit" value="Send" /></td> </tr> </table> </form> </body> </html>
Jump To Top of Thread