Jump to content

Recently Moved Website


poison6feet

Recommended Posts

Hi,

Earlier I was hosting my website on VPS and written in PHP, recently I moved this site to only webhosting services but due to some reason, the code is not responding and working properly.

For example,

I have used process.php to handle forms and session.php to handle session variables and database.php to handle data manupilations, but when I trying to add the user then I am getting this error, Fatal error: Call to undefined method MySQLDB::adduser(), however this was working fine.

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/164634-recently-moved-website/
Share on other sites

SORRY For unorganized CODE Formatting

 

 

class Session

{

  var $username;    //Username given on sign-up

  var $userid;      //Random value generated on current login

  var $userlevel;    //The level to which the user pertains

  var $time;        //Time user was last active (page loaded)

  var $logged_in;    //True if user is logged in, false otherwise

  var $userinfo = array();  //The array holding all user info

  var $url;          //The page url current being viewed

  var $referrer;    //Last recorded site page viewed

 

 

  /* Class constructor */

  function Session(){

      $this->time = time();

      $this->startSession();

  }

 

 

function startSession(){

      global $database;  //The database connection

      session_start();  //Tell PHP to start the session

 

      /* Determine if user is logged in */

      $this->logged_in = $this->checkLogin();

 

      /**

      * Set guest value to users not logged in, and update

      * active guests table accordingly.

      */

      if(!$this->logged_in){

        $this->username = $_SESSION['username'] = GUEST_NAME;

        $this->userlevel = GUEST_LEVEL;

        $database->addActiveGuest($_SERVER['REMOTE_ADDR'], $this->time);

      }

      /* Update users last active timestamp */

      else{

        $database->addActiveUser($this->username, $this->time);

      }

 

      /* Remove inactive visitors from database */

      $database->removeInactiveUsers();

      $database->removeInactiveGuests();

 

      /* Set referrer page */

      if(isset($_SESSION['url'])){

        $this->referrer = $_SESSION['url'];

      }else{

        $this->referrer = "/";

      }

 

      /* Set current url */

      $this->url = $_SESSION['url'] = $_SERVER['PHP_SELF'];

  }

On index page and login page and all other pages I have started the session

session_start();

include("include/session.php");

 

 

with in the Session.php file

 

 

  /* Update Statistics*/

 

function updatestats($username, $page){

global $database;

//echo "Entered";

return $database->updatestats($username, $page);

}

 

 

with in the database.php file

 

  /**

    * update daily stats

    */

  function updatestats($username, $page){

  $ip=$_SERVER['REMOTE_ADDR'];

  if ($username){

  $loggedin=$username;

  }

  else

  {

  $loggedin="Guest";

  }

  $datetime = getdate();

  $date = $datetime[mday]."/".$datetime[mon]."/".$datetime[year];

$time=$datetime[hours].":".$datetime[minutes].":".$datetime[seconds];

$page=str_replace("'","''",$page);

//echo $page;

      $q = "SELECT count FROM statistics where ipaddress = '$ip' and date='$date' and page='$page'";

 

      $result = mysql_query($q, $this->connection);

 

      if (mysql_numrows($result) > 0){

$row_count = mysql_fetch_assoc($result);

$count=$row_count['count']+1;

$q="Update statistics set LatestTime='$time', count=$count Where ipaddress = '$ip' and date='$date' and page='$page'";

      }

      else

      {

            $q = "Insert into statistics values('','$ip','$loggedin','$page','$date','$time','$time',1)";

 

      }

 

return mysql_query($q, $this->connection);

 

  }

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.