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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:35:29+00:00 2026-05-26T14:35:29+00:00

I am trying to get the login processor to match what the user types

  • 0

I am trying to get the login processor to match what the user types in, with the hard coded object array that contains the first name, last name, and password. I am not sure how to make the check between the login and the object array. I have 3 pages, the student.class.php, login.php, and processor.php.

I also need to use the session_start() and $_SESSION array but I am not sure how to implement this into my project. would I make a seperate session file, or include it into my processor.

Student.class.php

<?php

class Student 
{

    private $f_name;
    private $l_name;
    private $full_name;
    private $password;

    //Constructor method
    public function __construct($f_name,$l_name,$password) {
        $this->f_name = $f_name;
        $this->l_name = $l_name; 
        $this->password = $password;
    }



    function get_name(){
        $full_name = $this->f_name.' '.$this->l_name;
        return $full_name;
    }

    function get_level(){
        return $this->level;
    }

    function get_gender(){
        return $this->gender;
    }

    function get_password(){
        return $this->password;
    }
}
?>

login.php

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>

    <body>
    <?php

    require_once 'student.class.php';

    $students = array();

    $students[0] = new Student('Trey', 'Smith', 'senior', 'male', 'sailor1234');
    $students[1] = new Student('Kyle', 'McAulay', 'junior', 'male', 'abc123');
    $students[2] = new Student('Stacey', 'Keibler','senior','female', 'hotdawg23');
    $students[3] = new Student('Lindsey', 'Mullins', 'junior','female','gonoles69');
    $students[4] = new Student('Kenneth', 'Jaggers','senior', 'male', 'peterpanpan');
    $students[5] = new Student('Chad', 'Endris', 'sophomore', 'male','back2thefuture');

    ?>

    <h1>Sign up for our site!</h1>
    <form method="post" action="processor.php">     
        <fieldset>          
            <label>First Name</label>
            <input type="text" name="first_name"/>

            <label>Last Name</label>
            <input type="text" name="last_name"/>

            <label>Password</label>
            <input type="text" name="password"/>                    
        </fieldset>

        <br><input type="submit" value="Submit"></input></br>
     </body>
</html>

processor.php

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>

    <body>

    <?php

    require_once 'student.class.php';
    require_once 'login.php';

    function check_submit($field_to_check)
    {
        if (isset($_POST[$field_to_check]) && $_POST[$field_to_check] != '')
        {
            return TRUE;
        }
        else
        {
            return "Please fill in the $field_to_check category!";
        }
    }


    $errors = array();

    $_POST['first_name'] = strip_tags(trim($_POST['first_name']));
    $_POST['last_name'] = strip_tags(trim($_POST['last_name']));
    $_POST['password'] = strip_tags(trim($_POST['password']));


    if (check_submit('first_name') !== TRUE)
    {
        $errors[] = check_submit('first_name');
    }

    if (check_submit('last_name') !== TRUE)
    {
        $errors[] = check_submit('last_name');    
    }

    if (check_submit('password') !== TRUE)
    {
        $errors[] = check_submit('password');    
    }

    if (count($errors)> 0){
        echo "<ul>";
        foreach($errors as $message){
        echo "<li>$message</li>";
    }

    echo "</ul>";

    die();
    }

    ?>

    <h1>Thank you for registering <?php echo $_POST['first_name']."
    ".$_POST['last_name']?>!</h1>
    <h2>Your password was correct!</h2>

    </body>
</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-05-26T14:35:29+00:00Added an answer on May 26, 2026 at 2:35 pm

    Put session_start() at the top of any page you need to set/retrieve session data

    Upon login submission, loop through your students array, testing each one against your $_POST inputs. If you get a match, save the object to a session variable such as $_SESSION[‘student’]

    foreach ($students as $student) {
    
        if ($student->f_name == $_POST['f_name'] &&
            $student->l_lame == $_POST['l_lame'] &&
            $student->password == $_POST['password'] ) {
    
            $_SESSION['student'] = $student;
            break;
    
        }
    
    }
    

    This isn’t a great way to do this.. ideally you wouldn’t be instantiating a new object for every student unless you’re going to use all of them later.

    Also, on processor.php, you’re looking for $_POST[‘first_name’], but the name of the input field is ‘f_name’

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

Sidebar

Related Questions

I'm using PHP 4.3.9, Apache/2.0.52 I'm trying to get a login system working that
I'm trying to get all domains that are available in the Windows Login dialog
Good Evening, I am trying to get the login details after the user press
I'm trying to get some ideas about how to develop a web login screen.
Trying to get comfortable with jQuery and I have encountered some sample code that
I'm trying to use cURL to get past a login page, but in the
I created a django application with a user login/registration page. I am trying to
I created my first website in ASP.Net and I am trying to get it
I'm trying to execute an HTTP GET from my website to another website that
I am trying to build a rails login process with devise that will allow

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.