Form Validation Help

This is a discussion on "Form Validation Help" within the PHP Forum section. This forum, and the thread "Form Validation Help are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack (1) Thread Tools
  1 links from elsewhere to this Post. Click to view. #1  
Old Dec 12th, 2005, 16:19
New Member
Join Date: Dec 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Form Validation Help

Hello All,

My first post...

I've designed a contact form for a website that requires the entry of either a mobile number, home number or work number.

Any ideas as on what sort of coding I could use that would validate that a user has entered one of the above phone numbers?

I've played around with various if and switch statements that I found on the web but have had no luck.

Can anyone help?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Dec 12th, 2005, 16:38
Most Reputable Member
Join Date: Aug 2005
Location: North Wales, United Kingdom
Age: 21
Posts: 1,093
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Form Validation Help

Code: Select all
if ($number == null)
{
code for what u want to do here;
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Dec 12th, 2005, 16:59
New Member
Join Date: Dec 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Form Validation Help

Wow Quick Reply!

Just to clarify I have three text fields - I just want to validate that one of the three contact numbers has been entered by the user.

Something like this:

http://www.foxtons.co.uk/cgi-bin/con..._nhgt000233972
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Dec 12th, 2005, 18:00
Most Reputable Member
Join Date: Aug 2005
Location: North Wales, United Kingdom
Age: 21
Posts: 1,093
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Form Validation Help

Ye so you would need:
$number1 == null
$number2 == null
$number3 == null

etc.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Dec 13th, 2005, 08:52
New Member
Join Date: Dec 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Form Validation Help

Thanks but that's not working...

Does anyone know if this statement is correct:

if ((($mobile_phone ==""))(($home_phone ==""))(($work_phone ==""))){ "- You did not enter a contact number."; $error=1; }

I keep getting a parse error:

Parse error: parse error, unexpected '('
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Dec 13th, 2005, 13:31
Most Reputable Member
Join Date: Aug 2005
Location: North Wales, United Kingdom
Age: 21
Posts: 1,093
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Form Validation Help

Too many (()) it only needs one, example
Code: Select all
if($variable == null)
{
exit;
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Dec 13th, 2005, 19:37
Reputable Member
Join Date: Sep 2005
Location: Canada, BC
Age: 24
Posts: 239
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Form Validation Help

PHP: Select all

if ( empty($mobile_phone) || empty($home_phone) || empty($work_phone) )
{
  echo 
"- You did not enter a contact number.";
  
$error=1;

That is how I would do what you are trying to do.
However I probaly would use one of the php string evaluation functions to make sure they are giveing you a real phone number.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Dec 13th, 2005, 19:40
Most Reputable Member
Join Date: Aug 2005
Location: North Wales, United Kingdom
Age: 21
Posts: 1,093
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Form Validation Help

Thanks for that Phoenix
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
form, validation, help

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://webforumz.com/php-forum/4396-form-validation-help.htm
Posted By For Type Date
flash form validation This thread Refback Sep 5th, 2006 19:02

Similar Threads
Thread Thread Starter Forum Replies Last Post
Form validation help! psycho wolvesbane JavaScript Forum 16 Feb 12th, 2008 16:40
Form Validation cjrollo Flash & Multimedia Forum 0 Feb 22nd, 2007 17:33
Form Validation feebee JavaScript Forum 1 Aug 3rd, 2006 16:12
PHP Form Validation. kaz PHP Forum 2 Jul 22nd, 2006 20:47
PHP Form Validation ??? j4mes_bond25 PHP Forum 2 May 31st, 2006 23:08


All times are GMT. The time now is 02:30.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42