[SOLVED] Validate name field

This is a discussion on "[SOLVED] Validate name field" within the PHP Forum section. This forum, and the thread "[SOLVED] Validate name field are both part of the Program Your Website category.



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

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jan 13th, 2008, 14:42
SuperMember

SuperMember
Join Date: Jun 2007
Location: Northumberland, UK
Age: 45
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] Validate name field

Hi,
Does anyone have any idea how to make this php script name field a required name field, as at the moment the field can be left blank and the name is required.


PHP: Select all

if(isset($_REQUEST['name']) && !empty($_REQUEST['name']))
{
if(
preg_match("/[^a-z' -]/i",stripslashes($_REQUEST['name']))){$errors[] = "You have entered an invalid character in the name field";}

Thanks in advance for any help given.
__________________
Gary
Gladstone Websites
Reply With Quote

  #2 (permalink)  
Old Jan 13th, 2008, 15:08
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: Validate name field

It depends how the rest of the script works, but something like this should work...
Code: Select all
if(empty($_REQUEST['name']))
{
 $errors[] = "Name field is EMPTY!!!!!!!!!!!!!";
}
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Reply With Quote
  #3 (permalink)  
Old Jan 13th, 2008, 15:26
SuperMember

SuperMember
Join Date: Jun 2007
Location: Northumberland, UK
Age: 45
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Validate name field

Thanks spinal007 that works a treat.
__________________
Gary
Gladstone Websites
Reply With Quote
Reply

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Please help validate 4 css errors! Oak Web Page Design 3 Jan 10th, 2008 11:20
[SOLVED] Validate Form Class soloam JavaScript Forum 2 Nov 28th, 2007 14:51
[SOLVED] Page doesn't validate. mcdanielnc89 Web Page Design 9 Oct 23rd, 2007 05:19
Validate a certain field content Syd JavaScript Forum 6 Jan 1st, 2007 01:24
validate text field to db field jtesolin Classic ASP 1 Jul 18th, 2006 17:48


All times are GMT. The time now is 11:35.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs 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 43