Jump to content

Form validation failing


TomTees

Recommended Posts

Another bizzare thing that stopped working all of a sudden...

 

I have a registration form and this code no longer works...

	// Check for First Name.
	// Allow letters, space, period, apostrophe, and hyphen.
	if (preg_match('/^[A-Z\'.-]{2-20}$/i', $_POST['first_name'])){
		$fn = mysqli_real_escape_string($dbc, $_POST['first_name']);
	} else {
		// Add error-message to array.
		$reg_errors['first_name'] = 'Please enter your first name!';
	}

 

All day when I typed in a two letter answer - to speed up typing and testing - things worked fine, but now I get a built-in error message off to the side of the input box.

 

I typed 'ee' and that always worked before but no luck now.

 

The Reg Ex hasn't changed.

 

Could it be that there is a database connectivity issue that is screwing up my RegEx??

 

If I comment out all of the RegEx stuff then it works and my INSERT works - thanks to AlexWD  ;D

 

 

TomTees

 

 

Link to comment
Share on other sites

Just use:

 

'/[a-zA-Z\'.-]{2,20}$/'

 

I just noticed you are using a dash ('-') is should be a comma, as far as I know

 

UGH!!!  What a freshman mistake!!

 

(Looks like my elderly eyes failed me at nearly 2:00am last night!!)    :shy:

 

Thanks for the catch!!!

 

 

TomTees

 

 

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.