Simple.... do these checks.... and you'll be sweet as a nut

Adam

<?php

$sql = "SELECT nickname FROM tblUsers WHERE nickname = '$nickname''";
$result = mysql_query($sql);

$sql = "SELECT email FROM tblUsers WHERE email = '$email'";
$result2 = mysql_query($sql);

if (mysql_num_rows($result)){
        $error[] = "That nickname is already chosen";
}
        
if (mysql_num_rows($result2)){
        $error[] = "That username is already chosen";
}

if (!$error){
        // do the inserting here
}

?>


// you might have this at the top of your form to show the error messages
<?php
if ($error){
        echo "<p class=\"msg\">\n";
        for($i=0;$i<count($error);$i++){
                echo "$error[$i] . "<br>\n";
        }
        echo "</p>\n";
}
?>

> Hi all
>
>
>
> I am trying to create a registration area that uses a nickname and email
> pair.
>
>
>
> I need both to be unique.
>
>
>
> So how do I that either do not already exist then if unique insert into
> db.
>
>
>
> So
>
> if nickname exist then error = "sorry..."
>
> if email exist then error = "sorry..."
>
> else must be unique
>
> insert.
>
>
>
> I have been trying for hours know but cant get the twin check to work.
>
>
>
> Can get single check to work though.
>
>
>
> I thank you in advance for any thoughts or code examples
>
>
>
> Dave Carrera
>
> Php Developer
>
> http://davecarrera.freelancers.net
>
> http://www.davecarrera.com

Reply via email to