I have a function that insert new users to a database. If the input is somewhat bad or the username or email already excist i want it to return false.
This is what it looks like:
public function input( $username, $password, $email ){
if( $stmt = $this->mysqli->prepare("INSERT INTO users (username, password, email) VALUES (?, ?, ?)" )){
$stmt->bind_param('sss', $username, $password, $email);
$stmt->execute();
$stmt->close();
$this->mysqli->close();
return true;
}
else{
return false;
}
}
It works perfectly fine until I try to create a duplicate, it returns true, but doesnt affect the tabledata in the database as I can see.
1 Answer