0

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.

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by nagatron
0

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
    }
0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.