Not getting POST data from within class
<p>I am new to PHP and I have a project to complete as part of a bigger project to create a website for college. </p>

<p>I am trying to use the POST method in an HTML page to send data to a class named <code>user</code>. </p>

<ul>
<li>If the user has entered text into the input box, output markup that displays name, else</li>
<li>if the <code>isset()</code> method <code>return false</code> on the variable, PHP will <code>echo "notset";</code>.</li>
</ul>

<p>This seems simple enough, but no matter what I do, I cannot get the data I enter into the input box return, I keep getting "not set" returned. </p>

<p><strong>Form HTML</strong></p>

<pre><code>&lt;form method="post" action="user.php"&gt;
&lt;table cellpadding="5"&gt;
 &lt;tr&gt;
  &lt;td&gt;&lt;label for="firstname"&gt;Enter Firstname:&lt;/label&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" id="firstname" name="firstname" /&gt;&lt;br /&gt;&lt;/td&gt;
 &lt;/tr&gt;  
 &lt;tr&gt;
  &lt;td&gt;&lt;label for="surname"&gt;Enter Surname:&lt;/label&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text"   id="surname" name="surname" /&gt;&lt;br /&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt; &lt;label for="email"&gt;Email Address:&lt;/label&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" id="email" name="email" /&gt;&lt;br /&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;label for="password"&gt;Enter Password:&lt;/label&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="password" id="password" name="password" /&gt;&lt;br /&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;label for="renter"&gt;Re-Enter Password:&lt;/label&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="password" id="renter" name="renter" /&gt;&lt;br /&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;label for="address1"&gt;Address Line 1:&lt;/label&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" id="address1" name="address1" size="35"/&gt;&lt;br /&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;label for="address2"&gt;Address Line 2:&lt;/label&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="text"    id="address2" name="address2" size="35"/&gt;&lt;br /&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;label for="city"&gt;City:&lt;/label&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" id="city" name="city" /&gt;&lt;br /&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;label for="postcode"&gt;Postcode:&lt;/label&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" id="postcode"     name="postcode" /&gt;&lt;br /&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;label for="country"&gt;Country:&lt;/label&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" id="country" name="country" /&gt;&lt;br /&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td&gt;&lt;input type="submit" value="Submit Details" name="submit" class="button1"/&gt;&lt;/td&gt;
&lt;/table&gt;
&lt;/form&gt;
</code></pre>

<p>I am trying to get the <code>input name="firstname"</code> printed on the page first; then I will begin to worry about everything else. Below is my <code>class</code> and some more HTML I use to print the <code>firstname</code>.</p>

<p><strong>Result HTML</strong></p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
&lt;head&gt;&lt;/head
&lt;body&gt;
&lt;p&gt;thank you! user has been created&lt;/p&gt;
&lt;?php

$newuser = new user();
$theuser = $newuser-&gt;getfirstname();

echo $theuser;

?&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p><strong>user CLASS</strong></p>

<pre><code>&lt;?php

class user
{
    public $email;
    public $firstname;
    public $lastname;
    public $connection;

    function _construct()
    {
        $this-&gt;firstname= $_POST['firstname'];
        $this-&gt;lastname = $_POST['lastname'];
        $this-&gt;email=$_POST['email'];
    }

    public function  getfirstname()
    {
        if(isset($firstname))
        {
            return $this-&gt;firstname;
        }
        else
        {
            return "not set";
        } 
    }
}

?&gt;
</code></pre>
