Jump to content

VERY IMPORTANT question about validation using php


sudhakararaog

Recommended Posts

i am using php in order to validate a form where users register. please help me to solve the following validations.

 

1. name can have spaces. ex= john smith

presently the validation i am using is if( $fname == ""  || !eregi("^[a-zA-Z_]+$", $fname) )

i need the syntax which would accept a-zA-Z WITH A SPACE IN BETWEEN NAMES ex= john smith

 

2. text can have spaces and special characters ex= ref 100/abcd

presently the validation i am using is if( $depositnumber == ""  || !eregi("^[a-zA-Z0-9_]+$", $depositnumber) )

i need the syntax which would accept a-zA-Z0-9 WITH A SPACE IN BETWEEN AND SPECIAL CHARACTERS ex= ref 100/abcd

 

3. spaces in numbers. ex= 123 4567

presently the validation i am using is if( $phonenumber == ""  || !eregi("^[0-9]+$", $phonenumber) )

i need the syntax which would accept 0-9 WITH A SPACE IN BETWEEN ex= 123 4567

 

4. in case of [a-zA-Z0-9_] if i remove the "_" after 9 will it have a negative impact or is this a syntax due to which i

 

should i leave the "_" as part of [a-zA-Z0-9_]

 

5. using stripslashes() function

due to the above validation there is no way a user can enter special characters which could lead to sql injection. inspite of

 

this should i still use stripslashes to be on the safe side.

 

please provide the exact syntax for the above validations to works as specified for different scenarios.

 

thanks.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.