GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 14-Jul-2003, 03:16
skyloon skyloon is offline
Junior Member
 
Join Date: Jun 2003
Posts: 53
skyloon is an unknown quantity at this point

validate form


how to validate a form?
it will check whether it is empty or not, if yes, it will ask user to enter the value, the value for name can't in the numeric form, the IC Number can't in the string form. it also check the email is in the correct format.
thank you
  #2  
Old 14-Jul-2003, 07:20
Garth Farley Garth Farley is offline
Invalid Email Address
 
Join Date: May 2002
Location: Ireland
Posts: 638
Garth Farley is a jewel in the roughGarth Farley is a jewel in the roughGarth Farley is a jewel in the rough
Validation is essentially a bunch of IF statements, which check if some variable is good or not.

The first & most important is:
PHP Code:

if( !isset($id) ){ // means if $id is *not* set
          //$id is not set
          $pling = true;
}
else{  //it is set!
          $pling = false;
} 



Don't do if($id), because if $id is set to zero/false, the if's parameters will be false - even though it's set.

Say to check if $id is an integer between 1 and 100 (inclusive), have this:
PHP Code:

if(is_int($id) && $id <= 100 && $id >= 1){
         //$id is okay
}
else{
         //$id is bad, do something.
} 




Checking email addresses is tricky, using things called regular expressions, which essentially define a template for a string, and you see if your email address string fits the template or not.

Thankfully the work is done for you by many people, so do a google or look here: www.zend.com

GF
  #3  
Old 15-Jul-2003, 00:55
skyloon skyloon is offline
Junior Member
 
Join Date: Jun 2003
Posts: 53
skyloon is an unknown quantity at this point
thanx a lot
  #4  
Old 15-Jul-2003, 09:04
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough

validating valid email adress syntaxes


We have a function here to validate email address (syntax): http://www.desilva.biz/forum/viewtopic395.php

As usual, would appreciate feedback if it doesn't work for you (since I personally don't use it much).
 
 

Recent GIDBlogA Week in Kuwait by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why doesnt my form work correctly? rhino1616 Web Design Forum 2 06-Nov-2003 17:21
Automate a data change php form mjfmn MySQL / PHP Forum 4 20-Oct-2003 09:37
simple form from generated page zuzupus Web Design Forum 0 17-Sep-2003 09:27
form in a table cell blelisa Web Design Forum 1 19-Aug-2003 09:14
Best way to validate numbers (ids)? JdS MySQL / PHP Forum 1 20-Jan-2003 03:55

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 23:43.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.