Hello,

I am currently learning PHP. I am trying to implement a sign up page. The name at the same email address of the users in the database should give me an error message.

I don't know how to start with. I started this by searching the emails in the database and see if they exists already but then I am very confused.

Thanks

Member Avatar for cuonic

...

suppose you have field in database called email and php form field named email then

$email = mysql_real_escape_string($_POST['email']);
$sql = "SELECT * FROM users_table WHERE email='$email'";
$res = mysql_query($sql)
if($res){
    if(mysql_num_rows($res)>0){
        //email found
    else{
        //email not found
    }
}else{
// nothing came from db perhaps errors or such
}
//code totally untested!

Thanks for your replies. I think I have found the solution to my problem.

If (entered_name) in page is equal as (name) in database && (email_entered) in page is equal as (email) in databse then show error message

else insert entered details in database.

Can I do that?

Thanks for your replies. I think I have found the solution to my problem.

If (entered_name) in page is equal as (name) in database && (email_entered) in page is equal as (email) in databse then show error message

else insert entered details in database.

Can I do that?

that is it! go ahead implement it and mark thread solved :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.