PHP要求在功能问题

PHP要求在功能问题

本文介绍了PHP要求在功能问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我在理解问题或使以下情况正常工作时遇到问题:

我有一个登录页面,该页面具有以下内容:

database/dbsettings.php-包含dbconn.php的要求和对类连接的初始化.

methods.php包含各自类中的所有方法:
在这种情况下,登录类及其各自的功能

login_header.php只是包含格式/样式等的HTML页面.

现在onSubmit,设置了类并读取了方法,并为其指定了正确的参数.

问题是,dbsettings.php被忽略了,因此给了我错误:

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在dbconn.php中初始化了类dbconn



dbsettings.php has the initialisation of the class dbconn in dbconn.php

<?php
//require the class connection to set the database parameters
require("dbconn.php");

$db = new dbconn();

$db->setdatabasename("quzxwetm_attendance");
?>




第20行包含以下内容:




Line 20 has the following:

$resultset = $db->query($query);



在dbconn.php中,具有以下功能:



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());
        //$this->disconnect();
        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();

?>




为了正确读取dbconn.php中的函数查询,应该这样做吗?有帮助吗?

谢谢&问候,
Francesco




Would should be done in order for the function query in dbconn.php be read correctly? And help?

Thanks & Regards,
Francesco

推荐答案





第20行包含以下内容:




Line 20 has the following:



这篇关于PHP要求在功能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 05:51