Hi,
you have to perform a select query inside the methods isUserExistscustomer()
and $this->isUserExistsmobile()
and return boolean TRUE or FALSE.
For example:
public function isUserExistsmobile($mobile_no)
{
$stmt = $this->conn->prepare("SELECT id FROM np_system_users WHERE customer_mobileno = ?");
$stmt->bind_param('s', $mobile_no);
$stmt->execute();
$stmt->store_result();
return $stmt->num_rows > 0 ? TRUE : FALSE;
}
Do the same for the email. The mobile number should be trimmed, to avoid leading and trailing spaces that could trick the system and allow duplicates:
$mobile_no = trim($mobile_no);
You should also remove spaces, dashes, dots inside the string, i.e. convert 555-123 231
to 555123231
and you should match prefixes which can be expressed in two ways, for example the international prefix for USA is 001
which can be shorted to +1
.
So here you should decide if the client can insert prefixes manually or by a dropdown menu (select tag), and if you want to reject the input which is not composed just by digits.
Regarding the trim()
function the same applies to email addresses, where you should lower the case to avoid values like abc@some.tld
and Abc@some.tld
. You can use mb_strtolower()
or the MySQL function LOWER()
, however this depends also on the charset assigned to the table column: