Hallo to all, I have a problem on how to test an existing data from the database. . .I have this registration form which displays an error if the user inputs a username and emai address which already exist in the database. Please help me, I can't find any related problems which already been solved.

Perhaps the following:

//get username
$username='Bill Gates';
//validate
$username=mysql_real_escape_string($username);
//set the sql query
$result=mysql_query('SELECT * FROM `table` WHERE `usercolumn`="'.$username.'"');
//check if it exists
if (mysql_num_rows($result)>0) {
    //it exists
    } else {
    //it does not exist
    }

Thank you so much for the help. I just started learning PHP, I will try this and if it work I will mark solve. Thank you again so much.

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.