Is this the best way?
- From: japruim@xxxxxxxxxx (Jason Pruim)
- Date: Fri, 14 Mar 2008 12:12:56 -0400
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
- Follow-Ups:
- Re: [PHP] Is this the best way?
- From: Jochem Maas
- Re: [PHP] Is this the best way?
- From: Richard Heyes
- Re: [PHP] Is this the best way?
- From: "Dan Joseph"
- Re: [PHP] Is this the best way?
- Prev by Date: Re: [PHP] What's wrong the __autoload()?
- Next by Date: Re: [PHP] storing / processing login info (newbie stuff not in tutorials)
- Previous by thread: Sendmail question
- Next by thread: Re: [PHP] Is this the best way?
- Index(es):
Relevant Pages
|