error checking on guestbook form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mike08
Forum Commoner
Posts: 57
Joined: Mon Apr 19, 2004 3:18 am

error checking on guestbook form

Post 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>';
}
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Please use the BBCode to highltight your PHP!

Thanks

Mark
mike08
Forum Commoner
Posts: 57
Joined: Mon Apr 19, 2004 3:18 am

what's the bbcode - how do i use that

Post 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.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

whenever you insert any PHP code in your post do this

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

faq.php#21

Mark
Post Reply