Hello there,
I'm having a problem understanding or making the following scenario work well:
I have a login page which in terms has the following:
database/dbsettings.php - containing the require for the dbconn.php and initialization to the class connection.
methods.php containing all the methods in their respective class:
In this case, class Login with its respective functions
login_header.php is just the HTML page that contains the formatting/styles etc.
Now onSubmit, the classes are set and methods are read and given their correct parameters.
What the problem is, is that the dbsettings.php is being ignored, therefore giving me the error:
Fatal error
: Call to a member function query() on a non-object in
/home2/quzxwetm/public_html/attendance/methods.php
on line
20
dbsettings.php has the initialisation of the class dbconn in dbconn.php
<?php
require("dbconn.php");
$db = new dbconn();
$db->setdatabasename("quzxwetm_attendance");
?>
Line 20 has the following:
$resultset = $db->query($query);
and in the dbconn.php, there is the following function:
function query($query)
{
if ($connected == false)
{
$this->connect();
}
$resultset = mysql_query($query) or die(mysql_error());
return $resultset;
}
<?php
include_once 'database/dbsettings.php';
include_once 'methods.php';
require 'login_header.php';
?>
// Set the function for a successful form submission
function onSubmit($formValues)
{
$formValues = $formValues->loginFormPage->loginFormSection;
$username = $formValues->username;
$password = $formValues->password;
$encrypt = md5($password);//for checking with
$myLogin = new Login();
$myLogin->LoginAttendance($username, $password);
$userid = $_SESSION["userid"];
$ip = $_SERVER["REMOTE_ADDR"]; //Sender's IP
if($username == $_SESSION["username"] && $encrypt == $_SESSION["password"])
{
if(!empty($formValues->rememberMe))
{
/*$response = array('successPageHtml' => $got_password.'<p>Login Successful</p><p>We\'ll keep you logged in on this computer.</p>');
*/
$myLogin->LogLoginAttendance($userid,$ip);
$expire=time()+30; //month logged in
return array('redirect' => 'index1.php?exp='.$expire);
}
else {
/*$response = array('successPageHtml' => '<p>Login Successful</p><p>We won\'t keep you logged in on this computer.</p>'.$got_password);
*/
$myLogin->LogLoginAttendance($userid,$ip);
$expire=time()+60; //60sec logged in
return array('redirect' => 'index1.php?exp='.$expire);
}
}
else
{
$response = array('failureNoticeHtml' => 'Invalid username or password.', 'failureJs' => "$('#password').val('').focus();");
}
return $response;
}
// Process any request to the form
$login->processRequest();
?>
Would should be done in order for the function query in dbconn.php be read correctly? And help?
Thanks & Regards,
Francesco