Jump to content

Simple regex test fails


Lassie

Recommended Posts

I need to check that input is alpha numeric and use the following code which fails.

Is there a mistake in the eregi code?

if (eregi ('^[[:alnum:]]$', stripslashes(trim($_POST['address'])))) 
{
	$add = escape_data($_POST['address']);
} else {
  		$errors[] = 'You forgot to enter your address.';

}

Link to comment
https://forums.phpfreaks.com/topic/85373-simple-regex-test-fails/
Share on other sites

I realise that I also need to allow spaces in the address line so I have modified the expression but it still fails.

can anyone help please.

// Check for a address.
if (eregi ('^[[:alnum:]][[:space:]]{30}$', stripslashes(trim($_POST['address'])))) 
{
	$add = escape_data($_POST['address']);
} else {
  		$errors[] = 'You forgot to enter your address.';

}

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.