Example 147: Validate on Email, City, and Date

Description:   This WebSmart PHP example creates a Page At a Time Maintenance Program that checks for a valid email address, city field, and date format.

Action Customer Number Customer Name Address 1 City Email Address
Display Edit Delete
1 Music by the Numbers 7844 Franklin Blvd. Chicago judy@notarealaddress.com
Display Edit Delete
2 Up Tempo Distributors 801 - 9558 Abbey Rd. Phoenix stephaniel@notarealaddress.com
Display Edit Delete
3 OER Music 301 10th Street NW Calgary kevinK@notarealaddress.com
Display Edit Delete
4 Maritime Music 3200 Capitol Blvd Olympia Kim.Jeaneau@notarealaddress.com
Display Edit Delete
5 Swingin' Strings 2101 Louisiana Blvd NE Albuquerque tomjames@notarealaddress.com
Display Edit Delete
6 Cam's Country 86 Bedford Street New York cameron@notarealaddress.com
Display Edit Delete
7 The Rock Studio 909 12th Street Sacramento darrell@notarealaddress.com
Display Edit Delete
8 The Welsh Connection 39302 Sunnyside Way Chicago r.festinongg@notarealaddress.com
Display Edit Delete
9 Fruit of the Lute 7968 Vaughn Road Montgomery apple.dave@notarealaddress.com
Display Edit Delete
10 Phil's Philharmonic 5400 E Olympic Blvd Los Angeles philc@notarealaddress.comom
  1. Create a new "SQL Page at a Time" maintenance.


  2. Add this function into your PHP source code:
        function validate()
        {
          // Make all global variables available here
          foreach($GLOBALS as $arraykey=>$arrayvalue) 
    	  {
    	    if($arraykey[0]!='_' && $arraykey != 'GLOBALS')
    	      global $$arraykey;
    	  }
    
      
          if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $CMEMAIL)){	
       	    $msg = "Please enter a valid email address";
       	    wrtseg('RcdManage'); 
       	    exit;
          }else{
           $msg = "You have entered a valid email address"; 
          }  	
        }
        
    with the following:
        sample replacing text
        

Program Definition:   validate.phw

Rate This Example

Did this knowledge base article help you to achieve your goal?  Yes  No  Don't Know

Enter additional comments below.   If you want to hear back from us, include your contact information.