Hi all, I'm a bit stuck with my login script right now. I'm trying to move most of what (was) a working script into a class function. Here we go.
PHP Login script help.
7
Hi all,
I'm a bit stuck with my login script right now. I'm trying to move most of what (was) a working script into a class function. Here we go.
Esentially, user enters in name and password via form. Then it is checked below
Obviously, minus the form. Here's the function.
So my question is, why would mysqli_query($this->conn, $sql); be resulting in a boolean, not a number? Any pointerss on setting this straight?
I'm a bit stuck with my login script right now. I'm trying to move most of what (was) a working script into a class function. Here we go.
Esentially, user enters in name and password via form. Then it is checked below
PHP Code:
if(isset($_POST['submit'])){
$user=$_POST['user'];
$password=$_POST['password'];
//To ensure that none of the fields are blank when submitting the form if
if(isset($_POST['user']) && isset($_POST['password']))
{
$user = stripslashes($user);
$password = stripslashes($password); //<<For some protection use of the slashes
$db1=new dbmember();
$db1->openDB();
$result=$db1->logcon($user, $password);
if($result[0]==1)
{
session_start();
$_SESSION['user'] = $user;
$_SESSION['password'] = $password;
$_SESSION['loggedin'] = "true";
header("location:index.php");
}
else
{
print ('<div id="error">Acess denied, wrong username or password?</div>');
}
}
else
{
print ('<div id="error">Enter something!</div>');
}
}
Code:
function logcon($user, $password )
{
$esc_user = mysqli_real_escape_string($this->conn, $user);
$esc_password = mysqli_real_escape_string($this->conn,$password);
$sql = "SELECT ALL from USERS WHERE username ='{$user}' AND password='{$password}'";
$result = mysqli_query($this->conn, $sql);
$login = mysqli_fetch_array($result); //<< Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given
return $login;
} - dad2four
- dad2four
- [1] reply
- fabeledlabel
- [2] replies
- dad2four
Next Topics on Trending Feed
-
7