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
https://forums.phpfreaks.com/topic/219966-form-validation-failing/
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

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.