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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:09:40+00:00 2026-05-30T23:09:40+00:00

I have created a php person class and a very basic form. The form

  • 0

I have created a php person class and a very basic form. The form is to output the data to another page. This is a scaled down version it does not have all of the coding included but I think I have the jist of it. I cannot figure out why it is not working. It cant be anything big nor do I think I am missing any steps. Note my code below:

I’m not getting any errors at all… That data being keyed into the form is not rendering to my proceslogin.php page.

This is my form.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login</title>
</head>
                <div>
                    <form id="login" method="post" action="proceslogin.php">
                    <label for="firstname"> First Name: </label>
                    <input type="text" id="firstname" name="firstname" maxlength="100" tabindex="1" />

                    <label for="lastname"> Last Name: </label>
                    <input type="text" id="lastname" name="lastname" maxlength="100" tabindex="2" />

                    <input type="submit" id="submit" name="submit" value="Retrieve Full Name"/>

                    </form>

                </div>

<body>
</body>
</html>

This is my class

<?php
//Person Class
class Person{
    //attributes for the first and last name of the class
    private $firstname;
    private $lastname;

    /*Constructs the function*/
    public function __construct(){
    }

    /*Destroys the function*/
    public function __destruct(){
    }

    /*Get function*/
    public function __get($name) {
        return $this->$name;
    }

    /*Use the set function*/
    public function __set($name, $value) {
        $this->$name=$value;
    }

    /*Whis is what retrieves the values from memmory*/
    public function retrieve_full_name() {
        $fullname = $this->firstname . ' ' . $this->lastname;
        return $fullname;
    }
} //End of class
?>

This is the page the class object is to render in.

    <?php

        require_once('websiteconfig.inc.php');

    ?>





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Process Login</title>
</head>
<div class="container" id="shadow">
<div>
        <?php 
        //include for the header
            require_once(ABSOLUTE_PATH . 'header.inc.php');

            //This is the inlcude for the class files
            require_once('class/person.class.php');

            //Instantiate person class
            $person = new Person();

            //sets atributes for both firs and last names
            $person->firstname = $_POST['$firstname'];
            $person->firstname = $_POST['$lastname'];
        ?>
</div>

<p> 

<?
echo 'Your full name is ' . $person->retrieve_full_name() . ' .' ;
?> 


</p>
    <div>

    </hr>

    </div><!--End of Body-->
            <?php 
            //include for the footer
                require_once(ABSOLUTE_PATH . 'footer.inc.php');
            ?>
</div><!--end of header-->

<body>
</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-30T23:09:41+00:00Added an answer on May 30, 2026 at 11:09 pm

    You are using $lastname and $firstname when pulling from the _POST variable, which it should just be the name. You also had firstname set where lastname should be.

    So this is how your php code should look.

    PS: look into Smarty, it will help clean this all up.

    <?php
            require_once('websiteconfig.inc.php');
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Process Login</title>
    </head>
    <div class="container" id="shadow">
      <div>
        <?php 
            //include for the header
                require_once(ABSOLUTE_PATH . 'header.inc.php');
    
                //This is the inlcude for the class files
                require_once('class/person.class.php');
    
                //Instantiate person class
                $person = new Person();
    
                //sets atributes for both firs and last names
                $person->firstname = $_POST['firstname'];
                $person->lastname = $_POST['lastname'];
            ?>
      </div>
      <p>
        <?
    echo 'Your full name is ' . $person->retrieve_full_name() . ' .' ;
    ?>
      </p>
      <div>
        </hr>
      </div>
      <!--End of Body-->
      <?php 
                //include for the footer
                    require_once(ABSOLUTE_PATH . 'footer.inc.php');
                ?>
    </div>
    <!--end of header-->
    
    <body>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form which is submitted to a PHP page. The data from
I have created an form validation using ajax/php. Each text box is validated using
I have created a html page in php and upon submission i validates that
I have created this report using BIRT and phpjavabridge <?php header(Content-type: application/pdf); header(Content-Disposition: inline;
i have created a module with this among others this function in it: <?php
I have create a module(person) in my Zend Project. Then created a controller(PersonController.php) in
I have created a PHP-script to update a web server that is live inside
I have created a PHP script and I am lacking to extract the primary
How to manually create Friendly URLs? (PHP) So I have created simple php file
I have created a searchfrom.php for wordpress but then it's giving me a false

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.