PHPBuilder - Valiates



RSS Twitter
Snippets Algorithms

Valiates

by: kartik
|
May 17, 2005

Version: 1.0

Type: Function

Category: Algorithms

License: GNU General Public License

Description: Show how to validate various things. name, email, phone number, time, numerical data.





<?php
function validate ($first, $second, $timein, $timeout, $start, $end)

{
							if (!eregi('^[a-zA-Z]+$', $first))
								{$error = "please re-enter, first name not valid! <br />";
								 }
							elseif (!eregi('^[a-zA-Z]+$', $second))
								{$error =  "please re-enter, second name not valid!<br />";}
								elseif (!eregi('^[0-9]+:[0-9]+ [AMPM]+$', $timein))
								{$error =  "please re-enter, time in not valid! Make Sure time has capital AM or PM and time and AM or PM is seperated by a space..<br />";}
							elseif (!eregi('^[0-9]+:[0-9]+ [AMPM]+$', $timeout))
								{$error =  "please re-enter, time out not valid! Make Sure time has capital AM or PM and time and AM or PM is seperated by a space..<br />";}
								elseif (!eregi('^[0-9]+$', $start))
								{$error = "please re-enter, starting odometer reading not valid!<br />";}
							elseif (!eregi('^[0-9]+$', $end))
								{$error =  "please re-enter, ending odometer reading not valid!<br />";}
								elseif ( !($end > $start)){echo "<br />please re-enter, ending odometer reading is less than starting odometer reading!";}
							elseif ( $name =="name"
							|| $first == "Client First Name" || $second == "Client Second Name")
							{ $error ==  "<br />Field values not changed";}
							else ($error = "0");
							
							return $error;
							
							}
							?>

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
kartik

Comment:



Comment:

(Maximum characters: 1200). You have characters left.