+ 2
Data Already Exist
Hi, I make a registration form recently using PHP, how to produce an error/message when user input a name that already exist?
6 Answers
+ 3
Okay I misunderstood your question.
Well first of all you need to add new column called "id" with auto increment.
You check if the row exist using SELECT query and rowCount() in PDO or mysqli_num_rows in mysqli
+ 3
$pre = $db->prepare("SELECT id FROM users WHERE name=:name)
$pre->bindParam(":name", $name);
$pre->execute();
if($pre->rowCount()) {
echo "Name already exists";
} else {
}
+ 2
What do you mean exist?
How do you store them. Show me your table.
+ 2
oh ok tq ^^
+ 1
lets just assume I have a database name "login" with table named "users" with 3 column which is "email", " name", "password" with value "boyd@email.com", " boyd", "1234" respectively. And then, when another user register, he/she put the same name on the register form and submit, my code will scan the table in the database if the name already exist.
+ 1
btw i use xampp and mysql