Is this the best way?



Hi everyone,

I am attempting to add a little error checking for a very simple login system. The info is stored in a MySQL database, and I am using mysqli to connect to it. I have it working with the solution provided below, but I am wondering if this is the right way to do it or if there is a better way?

My thinking with this is if more then 1 record is returned from the database, then there is a issue... If only is returned then the username/password matched and I can safely show them the info...

$rowcnt = mysqli_num_rows($loginResult);
if($rowcnt !="1"){
echo "Auth failed";
die("Auth failed... Sorry");



}else{
while($row1 = mysqli_fetch_array($loginResult)) {
$_SESSION['user'] = $row1['loginName'];
$_SESSION['loggedin'] = "YES";
$table = $row1['tableName'];
$adminLevel = $row1['adminLevel'];
$authenticated = "TRUE";
echo "<BR>authentication complete";
}
return Array($table, $authenticated, $adminLevel);


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
japruim@xxxxxxxxxx





Relevant Pages

  • Re: a secure log-in system
    ... > I want to make a login system as secure as possible on a website I develop. ... > a mySQL database) ...
    (comp.lang.php)
  • Createing a Test DB Object.
    ... I need to test a bunch of code that extensively uses a mysql database, and I want to do it without actually writing to the database.. ... echo $this->realDB; ... Any idea why I would get the non-object error? ...
    (php.general)
  • Re: LAMP Question
    ... > reports generated from queries of the MySQL database. ... I'd probably do it right from php using MySQL to drive it, ... echo ""; ...
    (alt.os.linux.suse)
  • Re: Exporting data out of MySQL with PHP
    ... > I am working on a church project, I have built a MySQL database with a php ... I need to find out how to export data from the MySQL database ... cat << EOF | mysql ... echo "\end" ...
    (alt.php)
  • mail function and mysql data
    ... Now i try to send more than one data from mysql database so i must use ... echo $row; ... if i use mailfunction one parametar must be variable example $text ... I cant put more than one parameter in mail function or if i use $text ...
    (alt.php)