As an example:
PHP Code:
<?php
if (mysql_num_rows(mysql_query("SELECT email FROM users WHERE email = '" . mysql_real_escape_string($_POST['email']) . "'")) > 0) {
echo "That e-mail address already exists within the database";
}
else {
// E-mail address is unique, so set the account up....
}
?>
Some notes:
1. It's completely unnecessary to select all data (SELECT *) unless you absolutely NEED all the information or at least most of it. This is a bad habit to get into. If you're simply doing a validation you only need to SELECT a single field, because the actual validation check isn't performed on any of the retrieved content - thus retrieving it all is pointless and slower.
2. Make sure you sanitise and escape all user input. No user input can be trusted, so use functions like strip_tags and the all important mysql_real_escape_string to make your queries safe.
3. If your database is going to grow fairly large, remember to index the e-mail address field to increase performance.