Page 1 of 1

error checking on guestbook form

Posted: Mon Apr 19, 2004 4:37 am
by mike08
im used this error checking methods for email and username in my registration form

i want to use the same method but with an added one for comments as building a guestbook

can someone show me what to do please for checking this as am stuck, cheers.

Code: Select all

//Check for an email address.
if (eregi ("^[[]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$",stripslashes(trim($_POST['email'])))) {
	$e = escape_data($_POST['email']);

} else {

	$e = FALSE;
	echo '<p><font color="red" size"+1">Please enter a valid email address!</font></p>';
}

//Check for a username.
if (eregi ("^[[]_]{4,20}$", stripslashes(trim($_POST['username'])))) {
	$u = escape_data($_POST['username']);
} else {
	$u = FALSE;
	echo '<p><font color ="red" size="+1">Please enter a valid username!</font></p>';
}

Posted: Mon Apr 19, 2004 4:39 am
by JayBird
Please use the BBCode to highltight your PHP!

Thanks

Mark

what's the bbcode - how do i use that

Posted: Mon Apr 19, 2004 4:43 am
by mike08
what's the bbcode can you explain please?

by the way thanks my basic poll works now - moving on to the guestbook as you can see.

Posted: Mon Apr 19, 2004 4:47 am
by JayBird
whenever you insert any PHP code in your post do this

[syntax=php]***ALL YOUR CODE HERE***[/syntax]

faq.php#21

Mark