I slightly modified the Select Exists function that I found on a stackoverflow answer. How do I access the result of the EXISTS
query?
function uniqueexists($dbHandle,$tablename,$fieldname='username',$value) {
$sql = 'SELECT EXISTS(SELECT * FROM `'.$tablename.'` WHERE `'.$fieldname.'` = ? LIMIT 1)';
$stmt = mysqli_prepare($dbHandle, $sql);
mysqli_stmt_bind_param($stmt, 's',$value);
$sqlResult = mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$exists = ... // How to use the $sqlResult or the $result? ...
return $exists;
}
With: username Index varchar(255) utf8_german2_ci
The fieldname's entries are set to unique.