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 7932469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:01:47+00:00 2026-06-03T21:01:47+00:00

I just can’t figure it out.. but i got a feeling the problem is

  • 0

I just can’t figure it out.. but i got a feeling the problem is around there when im throwing the exception messages. I got almost the same code in my registration class. There is just give the errors array the messages normaly like $this->errors[] = “some error”.

<?php


class class_login 
{
    private $id;
    private $username;
    private $password;
    private $passmd5;

    private $errors;
    private $access;
    private $login;
    private $ltoken;

    public function __cunstruct()
    {
        $this->errors = array();

        $this->login  = isset($_POST['login'])? 1:0;
        $this->access = 0;
        $this->ltoken  = $_POST['ltoken'];
        $this->id     = 0;
        $this->username = ($this->login)? $this->filter($_POST['lusername']) : $_SESSION['username'];
        $this->password = ($this->login)? $this->filter($_POST['lpassword']) : '';
        $this->passmd5 = ($this->login)? md5($this->password) : $_SESSION['password'];

    }

    public function isLoggedIn()
    {
        ($this->login)? $this->verifyPost() : $this->verifySession();

        return $this->access;
    }

    public function filter($var)
    {
        return preg_replace('/[^a-zA-Z0-9]/','',$var);
    }

    public function verifyPost()
    {
        try
        {
            if(!$this->tokenValid())
                throw new Exception('Invalid Form Submission!');
            if(!$this->isDataValid())
                throw new Exception('Ivalid Form Data!');
            if(!$this->verifyDatabase())
                throw new Exception('Invalid Username/Password!');

            $this->access = 1;
            $this->registerSession();
        }
        catch(Exception $e)
        {
            $this->errors[] = $e->getMessage();
        }
    }

    public function verifySession()
    {
        if($this->sessionExist() && $this->verifyDatabase())
        $this->access = 1;
    }

    public function verifyDatabase()
    {
        include('db_connect.php');

        $data = mysql_query("SELECT ID FROM users WHERE username = '($this->username)' AND password = '($this->passmd5)'");

        if (mysql_num_rows($data))
        {
            list($this->id) = @array_values(mysql_fetch_assoc($data));

            return true;
        }
        else
            return false;

       }

    public function isDataValid()
    {
        return (preg_match('/[^a-zA-Z0-9](5,12)$/',  $this->username) && preg_match('/[^a-zA-Z0-9](5,12)$/',  $this->password))? 1:0;
    }

    public function tokenValid()
    {
        return (!isset($_SESSION['ltoken']) || $this->ltoken != $_SESSION['ltoken'])? 0 : 1;
    }

    public function registerSession()
    {
        $_SESSION['ID']       = $this->id;
        $_SESSION['username'] = $this->username;
        $_SESSION['password'] = $this->passmd5;
    }

    public function sessionExist()
    {
        return (isset($_SESSION['username']) && isset($_SESSION['password']))? 1 : 0;
    }

    public function show_errors()
    {
        foreach($this->errors as $key=>$value)
            echo $value."</br>";
    }


}

?>
  • 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-03T21:01:49+00:00Added an answer on June 3, 2026 at 9:01 pm

    The constructor is called __construct, not __cunstruct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Probably some simple derp but I just can't figure this out, I'm using almost
I just can't figure it out how to set custom validator messages in Zend_Form
I just can't figure out why there is extra grey space on the right
I've got a case where I just can't figure out how to get Ant
I just can't figure this out - I've tried positioning, floating and z-index, but
Just can't seem to figure this out, how to prevent the outer loop continuing
I just can't figure out why i get the error message, I have tried
I just can't figure out how to draw on a bitmap (with the help
I just can't seem to figure out how to make efficient and clean looking
I just can't figure this out, for some reason this: $string = #mainparent {

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.