Form value validation: not empty : Form Validation « Form « PHP

PHP
1. Chart
2. Class
3. Components
4. Cookie Session
5. Data Structure
6. Data Type
7. Date
8. Design Patterns
9. Development
10. DNS
11. Email
12. File Directory
13. Form
14. Functions
15. Graphics Image
16. HTML
17. Language Basics
18. Login Authentication
19. Math
20. MySQL Database
21. Network
22. Operator
23. PDF
24. Reflection
25. Statement
26. String
27. Utility Function
28. Web Services SOAP WSDL
29. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
PHP » Form » Form Validation 
Form value validation: not empty

<HTML>
<BODY>
<FORM METHOD="POST" ACTION="FormErrorCheck.php">
<H1>Contact Information</H1>
<TABLE>

<TR>
  <TD><B>Nickname:</B></TD>
  <TD><INPUT TYPE="TEXT" NAME="nickname"></TD>
</TR>

<TR>
  <TD>Title:</TD>
  <TD><INPUT TYPE="TEXT" NAME="title"></TD>
</TR>

<TR>
  <TD><B>First Name:</B></TD>
  <TD><INPUT TYPE="TEXT" NAME="firstname"></TD>
</TR>

<TR>
  <TD>Middle Name:</TD>
  <TD><INPUT TYPE="TEXT" NAME="middlename"></TD>
</TR>

<TR>
  <TD><B>Last Name:</B></TD>
  <TD><INPUT TYPE="TEXT" NAME="lastname"></TD>
</TR>

<TR>
  <TD><B>Primary Email:</B></TD>
  <TD><INPUT TYPE="TEXT" NAME="email"></TD>
  <TD WIDTH="20">&nbsp;</TD>
  <TD>Secondary Email:</TD>
  <TD><INPUT TYPE="TEXT" NAME="secondaryemail"></TD>
</TR>

<TR>
  <TD>Company Name:</TD>
  <TD><INPUT TYPE="TEXT" NAME="companyname"></TD>
</TR>

<TR>
  <TD>Office Address:</TD>
  <TD><INPUT TYPE="TEXT" NAME="officeaddres1"></TD>
  <TD WIDTH="20">&nbsp;</TD>
  <TD>Home Address:</TD>
  <TD><INPUT TYPE="TEXT" NAME="homeaddress"></TD>
</TR>

<TR>
  <TD></TD>
  <TD><INPUT TYPE="TEXT" NAME="officeaddress2"></TD>
</TR>

<TR>
  <TD>City:</TD>
  <TD><INPUT TYPE="TEXT" NAME="officecity"></TD>
  <TD WIDTH="20">&nbsp;</TD>
  <TD>&nbsp;</TD>
  <TD><INPUT TYPE="TEXT" NAME="homecity"></TD>
</TR>

<TR>
  <TD>State:</TD>
  <TD><INPUT TYPE="TEXT" NAME="officestate"></TD>
  <TD WIDTH="20">&nbsp;</TD>
  <TD>&nbsp;</TD>
  <TD><INPUT TYPE="TEXT" NAME="homestate"></TD>
</TR>

<TR>
  <TD>Zip:</TD>
  <TD><INPUT TYPE="TEXT" NAME="officezip"></TD>
  <TD WIDTH="20">&nbsp;</TD>
  <TD>&nbsp;</TD>
  <TD><INPUT TYPE="TEXT" NAME="homezip"></TD>
</TR>

<TR>
  <TD>Phone:</TD>
  <TD><INPUT TYPE="TEXT" NAME="officephone"></TD>
  <TD WIDTH="20">&nbsp;</TD>
  <TD>&nbsp;</TD>
  <TD><INPUT TYPE="TEXT" NAME="homephone"></TD>
</TR>

<TR>
  <TD>Birthday:</TD>
  <TD><INPUT TYPE="TEXT" NAME="birthday"></TD>
</TR>

<TR>
  <TD>Spouse Name:</TD>
  <TD><INPUT TYPE="TEXT" NAME="spousename"></TD>
  <TD WIDTH="20">&nbsp;</TD>
  <TD>Childrens' Names:</TD>
  <TD><INPUT TYPE="TEXT" NAME="children"></TD>
</TR>

<TR>
  <TD>Anniversary:</TD>
  <TD><INPUT TYPE="TEXT" NAME="anniversary"></TD>
</TR>

</TABLE>

<BR>
<BR>
<BR>
<INPUT TYPE="SUBMIT" VALUE="Submit">
<BR>
<BR>
<INPUT TYPE="RESET"  VALUE="Clear the Form">

</FORM>
</BODY>
</HTML>

<!-- FormErrorCheck.php
<HTML>
<BODY>
<?php

  $errors=0;
  if (!trim($nickname)) {
      echo "<BR><B>Nickname</B> is required.";
     $errors++;
  }
 
  if (!trim($firstname)) {
      echo "<BR><B>First name</B> is required.";
     $errors++;
  }
 
  if (!trim($lastname)) {
      echo "<BR><B>Last name</B> is required.";
      $errors++;
  }
 
  if (!trim($email)) {
      echo "<BR><B>Primary email address</B> is required.";
      $errors++;
  }

  if ($errors > 0)
      echo "<BR><BR><BR>Please use your browser's back button " .
        "to return to the form, and correct error(s)";
 
?>

</BODY>
</HTML>
-->

           
       
Related examples in the same category
1. Form Data Validation With Error Count
2. A Sample Form Element Validation Function
3. Displaying error messages with the form
4. Elementary Form Validation
5. Form Example for the Form Validator Script
6. Validating form data
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.