PHP Login script help.
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
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>');
}
}
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 -
Thanks
SignatureDONT LOOK{{ DiscussionBoard.errors[8354275].message }} -
-
dad2four -
Thanks - 1 reply
SignatureDONT LOOK{{ DiscussionBoard.errors[8354279].message }}-
fabeledlabel -
Thanks - 2 replies
{{ DiscussionBoard.errors[8354398].message }}-
dad2four -
Thanks
SignatureDONT LOOK{{ DiscussionBoard.errors[8354879].message }} -
-
dad2four -
Thanks
SignatureDONT LOOK{{ DiscussionBoard.errors[8354891].message }} -
-
-
-
dad2four -
Thanks
SignatureDONT LOOK{{ DiscussionBoard.errors[8354733].message }} -