Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8407881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:29:26+00:00 2026-06-09T23:29:26+00:00

so after hours on the web searching for smallest details or solution for this

  • 0

so after hours on the web searching for smallest details or solution for this error I still can’t fix it

The errors :

Notice: Undefined variable: Login in C:\xampp\htdocs\up\administration\adduser.php on line 3

Fatal error: Call to a member function AddUser() on a non-object in C:\xampp\htdocs\up\administration\adduser.php on line 3

These errors are from adduser.php which contains

<?php
require_once('LoginClass.php');
$Login->AddUser('Test','test312');
?>

And this is the LoginClass.php

<?php

class Login {

//Username Variables
private $username;
private $password;

//MySQL Variables
private $Host;
private $MySQLUsername;
private $MySQLPassword;
private $Database;
private $Conn;


//Constructor
public function Login()
{
    session_start();
    $this->Host = "localhost";
    $this->MySQLUsername = "root";
    $this->MySQLPassword = "";
    $this->Database = "up";

    $this->Connection();

    unset($this->Host);
    unset($this->MySQLUsername);
    unset($this->MySQLPassword);
    unset($this->Database);
}
//**********************
//Mysql Functions
//********************** 
public function Connection()
{
    $this->Conn = @mysql_connect($this->Host,$this->MySQLUsername,$this->MySQLPassword);

    if($this->Conn)
    {
        mysql_select_db($this->Database) OR die('Could not select DB');
    }
    else
    {
        die(mysql_error());
    }  
}

public function Query($sql)
{
    $result = mysql_query($sql);

    if(!$result)
    {
        die(mysql_error());
    }

    return $result;
}

public function Disconnect()
{
    mysql_close($this->Conn);
}

//Escapes bad values for MySQL to prevent SQL injections.
public function EscapeString($badstring)
{
    if(!get_magic_quotes_gpc())
    {
        $goodstring = addslashes($badstring);
    }
    else
    {
        $goodstring = stripslashes($badstring);
    }

    $goodstring = mysql_real_escape_string($badstring);

    return $goodstring;
}

public function EncryptPassword($password)
{
  return sha1(md5($password));  
} 
//Check if the user can login
public function CheckLogin($username,$password)
{
    $this->username = $this->EscapeString($username); 
    $this->password = $this->EscapeString($this->EncryptPassword(($password)));

    $result = $this->Query("SELECT * FROM `users` WHERE `username` = '$this->username' AND `password` = '$this->password' LIMIT 1");

    //If we get one result we know the login is right.
    if(mysql_num_rows($result) == 1)
    {
        $this->username = $username;
        $_SESSION['username'] = $this->username;
        $_SESSION['authorized'] = 1; 

        header('location:Private.php');
    }
    else 
    {
        die('Invalid Login');
    }

}
//Add a user
public function AddUser($username,$password)
{
    //$username = $this->EscapeString($username);
    //$password = $this->EscapeString($this->EncryptPassword($password));
    $username = $this->$username;
    $password = $this->$this->EncryptPassword($password);

    $result = $this->Query("INSERT INTO `users` (username,password) VALUES ('$username','$password')");
}
//Takes the result of a query and puts the information into an array
public function Result_To_Array($result)
{
    $result_array = array();

    for ($i=0; $row = mysql_fetch_array($result); $i++) 
    {
        $result_array[$i] = $row;
    }

    return $result_array;

}
//Delete user
public function DeleteUser($username)
{
    $username = $this->EscapeString($username);

    $result = $this->Query("DELETE FROM `users` WHERE `username` = '$username' LIMIT 1");

}
//Checks if the user is authorized or not
public function IsAuth()
{
    if(isset($_SESSION['username']) && $_SESSION['authorized'] == 1)
    return true;

    else
    {
        die('You are not authorized to view this information');
        header('login.html');
    }    
}
//Shows user's IP
public function GetIP()
{
    return $_SERVER['REMOTE_ADDR'];
}
//Display all users
public function ShowUsers()
{
    $users = $this->Result_To_Array($this->Query("SELECT * FROM `users`"));

    foreach($users as $user)
    {
        echo $user['username']."<br />";
    } 
}

public function LogOut()
{

     session_destroy();

     header('location:login.html');
}
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:29:28+00:00Added an answer on June 9, 2026 at 11:29 pm

    you should create new object Login() :

    require_once('LoginClass.php');
    $Login = new Login();
    $Login->AddUser('Test','test312');
    

    or call the function directly like this :

    require_once('LoginClass.php');
    Login::AddUser('Test','test312');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After HOURS of searching the web for a fix to IE8 and jQuery form
I am wondering if anyone can help me. After hours of searching tirelessly on
Hello all! This is my first post on stackoverflow. After hours of searching and
After a few hours of searching the web I couldn't find much help on
After hours of searching the web (including SO), I am requesting advice from the
This is a very simple question, but after a few hours surfing the web
after hours of googeling and searching within SO, I finaly come to the place
After hours I am giving up on debugging the following: This works: URL[] urls
I am asking for help, after hours of trying to figure this out myself.
Alright, I finally got this code to work after hours of toiling: Dim path

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.