Issue with Object oriented concepts in php
<p>I created a file by name classperson.php where I declared all the variables . </p>

<pre><code>&lt;?php
class person1
{
    var $location;
    var $effective;
    var $training;
    var $treated;
    var $effort;
    var $information;
    var $recognition;
    var $valued;
    var $supervisor;
    var $informed;
    var $job;
    var $treats;
    var $satisfy;
    var $workgroup;
    var $utc;
    var $skills;

    function set_location($new_location)
    {
        $this-&gt;location=$new_location;
    }
    function get_location()
    {
        return $this-&gt;location;
    }


    function set_effective($new_effective)
    {
        $this-&gt;effective=$new_effective;
    }
    function get_effective()
    {
        return $this-&gt;effective;
    }



    function set_training($new_training)
    {
            $this-&gt;training=$new_training;
    }
    function get_training()
    {
            return $this-&gt;training;
    }



    function set_treated($new_treated)
    {
        $this-&gt;treated=$new_treated;
    }
    function get_treated()
    {
        return $this-&gt;treated;
    }




    function set_effort($new_effort)
    {
        $this-&gt;effort=$new_effort;
    }
    function get_effort()
    {
        return $this-&gt;effort;
    }



    function set_information($new_information)
    {
        $this-&gt;information=$new_information;
    }
    function get_information()
    {
            return $this-&gt;information;
    }



    function set_recognition($new_recognition)
    {
        $this-&gt;recognition=$new_recognition;
    }
    function get_recognition()
    {
        return $this-&gt;recognition;
    }



    function set_valued($new_valued)
    {
        $this-&gt;valued=$new_valued;
    }
    function get_valued()
    {
            return $this-&gt;valued;
    }



    function set_supervisor($new_supervisor)
    {
        $this-&gt;supervisor=$new_supervisor;
    }
    function get_supervisor()
    {
        return $this-&gt;supervisor;
    }



    function set_informed($new_informed)
    {
        $this-&gt;informed=$new_informed;
    }
    function get_informed()
    {
        return $this-&gt;informed;
    }



    function set_job($new_job)
    {
        $this-&gt;job=$new_job;
    }
    function get_job()
    {
            return $this-&gt;job;
    }



    function set_treats($new_treats)
    {
        $this-&gt;treats=$new_treats;
    }
    function get_treats()
    {
        return $this-&gt;treats;
    }



    function set_satisfy($new_satisfy)
    {
        $this-&gt;satisfy=$new_satisfy;
    }
    function get_satisfy()
    {
            return $this-&gt;satisfy;
    }



    function set_workgroup($new_workgroup)
    {
        $this-&gt;workgroup=$new_workgroup;
    }
    function get_workgroup()
    {
            return $this-&gt;workgroup;
    }



    function set_utc($new_utc)
    {
        $this-&gt;utc=$new_utc;
    }
    function get_utc()
    {
        return $this-&gt;utc;
    }



    function set_skills($new_skills)
    {
        $this-&gt;skills=$new_skills;
    }
    function get_skills()
    {
        return $this-&gt;skills;
    }
}
?&gt;
</code></pre>

<p>Later I have Included this file in the oopossurvey.php . This is a form which has 5 pages</p>

<p>Take a look into the code </p>

<pre><code>&lt;?php
session_start();
$session=session_id();
$_SESSION['session']=$session;
?&gt;
&lt;html&gt;
&lt;body&gt;
&lt;form action="oopssurvey.php" method="post"&gt;
Where do you work?&lt;br/&gt;
&lt;Input type ="radio" name="location" value="USA" &lt;?php if($_SESSION['location'] == 'USA') echo "checked='checked'" ?&gt;/&gt;In the United states&lt;br/&gt;
&lt;Input type ="radio" name="location" value="India" &lt;?php if($_SESSION['location'] == 'India') echo "checked='checked'" ?&gt;/&gt;Outside of the United states&lt;br/&gt;

&lt;input name="Operation1" type="submit" value="saveandresume" /&gt;
&lt;input name="Operation2" type="submit" value="next" /&gt;

&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

&lt;?php
session_start();

if($_SESSION['session']==$session)
{
$location=$_SESSION['location'];
}
else
{
$_SESSION['location'] = $_POST['location'];
}
?&gt;

&lt;html&gt;

&lt;body&gt;

&lt;form action="oopssurvey.php" method="post"&gt;

In my work group, we are actively involved in making our work processes more effective and efficient (simpler, faster, etc.) using ACE.&lt;br/&gt;
&lt;Input type ="radio" name="effective" value="Agree"/&gt;Agree&lt;br/&gt;
&lt;Input type ="radio" name="effective" value="Agreenordisagree"/&gt;Neither Agree nor Disagree&lt;br/&gt;
&lt;Input type ="radio" name="effective" value="disagree"/&gt;Disagree&lt;br/&gt;

I have received the training I need to understand and implement ACE in my work group.&lt;br/&gt;
&lt;Input type ="radio" name="training" value="Agree"/&gt;Agree&lt;br/&gt;
&lt;Input type ="radio" name="training" value="Agreenordisagree"/&gt;Neither Agree nor Disagree&lt;br/&gt;
&lt;Input type ="radio" name="training" value="disagree"/&gt;Disagree&lt;br/&gt;

All employees at the company are treated fairly regardless of differences.&lt;br/&gt;
&lt;Input type ="radio" name="treated" value="Agree"/&gt;Agree&lt;br/&gt;
&lt;Input type ="radio" name="treated" value="Agreenordisagree"/&gt;Neither Agree nor Disagree&lt;br/&gt;
&lt;Input type ="radio" name="treated" value="disagree"/&gt;Disagree&lt;br/&gt;

Sufficient effort is made to get the opinions and thoughts of the people who work here.&lt;br/&gt;
&lt;Input type ="radio" name="effort" value="Agree"/&gt;Agree&lt;br/&gt;
&lt;Input type ="radio" name="effort" value="Agreenordisagree"/&gt;Neither Agree nor Disagree&lt;br/&gt;
&lt;Input type ="radio" name="effort" value="disagree"/&gt;Disagree&lt;br/&gt;

&lt;input name="Operation3" type="submit" value="saveandresume" /&gt;
&lt;input name="Operation4" type="submit" value="next" /&gt;
&lt;input name="Operation5" type="submit" value="back" /&gt;

&lt;/form&gt;

&lt;/body&gt;

&lt;/html&gt;


 &lt;?php
session_start();

if($_SESSION['session']==$session)
{

    $effective=$_SESSION['effective'];

    $training=$_SESSION['training'];

    $treated=$_SESSION['treated'];

    $effort=$_SESSION['effort'];
}
else
{
    $_SESSION['effective']=$_POST['effective'];
    $_SESSION['training']=$_POST['training'];
    $_SESSION['treated']=$_POST['treated'];
    $_SESSION['effort']=$_POST['effort'];
}

?&gt;

&lt;html&gt;
&lt;body&gt;
&lt;form action="oopssurvey.php" method="post"&gt;

How satisfied are you with the information you receive from management on what's going on in the company?&lt;br/&gt;
&lt;Input type ="radio" name="information" value="agree"/&gt;Agree&lt;br/&gt;
&lt;Input type ="radio" name="information" value="Agreenordisagree"/&gt;Neither Agree nor Disagree&lt;br/&gt;
&lt;Input type ="radio" name="information" value="disagree"/&gt;Disagree&lt;br/&gt;

How satisfied are you with the recognition you receive for doing a good job?&lt;br/&gt;
&lt;Input type ="radio" name="recognition" value="agree"/&gt;Agree&lt;br/&gt;
&lt;Input type ="radio" name="recognition" value="Agreenordisagree"/&gt;Neither Agree nor Disagree&lt;br/&gt;
&lt;Input type ="radio" name="recognition" value="disagree"/&gt;Disagree&lt;br/&gt;

I feel valued as an employee of the company.&lt;br/&gt;
&lt;Input type ="radio" name="valued" value="agree"/&gt;Agree&lt;br/&gt;
&lt;Input type ="radio" name="valued" value="Agreenordisagree"/&gt;Neither Agree nor Disagree&lt;br/&gt;
&lt;Input type ="radio" name="valued" value="disagree"/&gt;Disagree&lt;br/&gt;

My immediate supervisor does a good job of coaching/guiding me.&lt;br/&gt;
&lt;Input type ="radio" name="supervisor" value="agree"/&gt;Agree&lt;br/&gt;
&lt;Input type ="radio" name="supervisor" value="Agreenordisagree"/&gt;Neither Agree nor Disagree&lt;br/&gt;
&lt;Input type ="radio" name="supervisor" value="disagree"/&gt;Disagree&lt;br/&gt;

&lt;input name="Operation6" type="submit" value="saveandresume" /&gt;
&lt;input name="Operation7" type="submit" value="next" /&gt;
&lt;input name="Operation8" type="submit" value="back" /&gt;

&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

&lt;?php
session_start();


if($_SESSION['session']==$session)
{

$information=$_SESSION['information'];

$recognition=$_SESSION['recognition'];

$valued=$_SESSION['valued'];

$supervisor=$_SESSION['supervisor'];
}
else
{
    $_SESSION['information']=$_POST['information'];
    $_SESSION['recognition']=$_POST['recognition'];
    $_SESSION['valued']=$_POST['valued'];
    $_SESSION['supervisor']=$_POST['supervisor'];
}
?&gt;
&lt;html&gt;

&lt;body&gt;

&lt;form action="oopssurvey.php" method="post"&gt;

I feel well informed about what is expected in my job.&lt;br/&gt;
&lt;Input type ="radio" name="informed" value="agree"/&gt;Agree&lt;br/&gt;
&lt;Input type ="radio" name="informed" value="Agreenordisagree"/&gt;Neither Agree nor Disagree&lt;br/&gt;
&lt;Input type ="radio" name="informed" value="disagree"/&gt;Disagree&lt;br/&gt;

Overall, how good a job do you feel is being done by your immediate supervisor&lt;br/&gt;
&lt;Input type ="radio" name="job" value="agree"/&gt;Agree&lt;br/&gt;
&lt;Input type ="radio" name="job" value="Agreenordisagree"/&gt;Neither Agree nor Disagree&lt;br/&gt;
&lt;Input type ="radio" name="job" value="disagree"/&gt;Disagree&lt;br/&gt;

My immediate supervisor treats me with respect and dignity.&lt;br/&gt;
&lt;Input type ="radio" name="treats" value="agree"/&gt;Agree&lt;br/&gt;
&lt;Input type ="radio" name="treats" value="Agreenordisagree"/&gt;Neither Agree nor Disagree&lt;br/&gt;
&lt;Input type ="radio" name="treats" value="disagree"/&gt;Disagree&lt;br/&gt;

How satisfied are you with your involvement in the decisions that affect your work?&lt;br/&gt;
&lt;Input type ="radio" name="satisfy" value="agree"/&gt;Agree&lt;br/&gt;
&lt;Input type ="radio" name="satisfy" value="Agreenordisagree"/&gt;Neither Agree nor Disagree&lt;br/&gt;
&lt;Input type ="radio" name="satisfy" value="disagree"/&gt;Disagree&lt;br/&gt;

&lt;input name="Operation9" type="submit" value="saveandresume" /&gt;
&lt;input name="Operation10" type="submit" value="next" /&gt;
&lt;input name="Operation11" type="submit" value="back" /&gt;

&lt;/form&gt;

&lt;/body&gt;

&lt;/html&gt;

&lt;?php

session_start();

if($_SESSION['session']==$session)
{

$informed=$_SESSION['informed'];

$job=$_SESSION['job'];

$treats=$_SESSION['treats'];

$satisfy=$_SESSION['satisfy'];
}
else
{
    $_SESSION['informed']=$_POST['informed'];
    $_SESSION['job']=$_POST['job'];
    $_SESSION['treats']=$_POST['treats'];
    $_SESSION['satisfy']=$_POST['satisfy'];
}
?&gt;

&lt;html&gt;

&lt;body&gt;

&lt;form action="oopssurvey.php" method="post"&gt;

Day-to-day decisions and activities in my work group demonstrate that quality is a top priority.
&lt;Input type ="radio" name="workgroup" value="agree"/&gt;Agree&lt;br/&gt;
&lt;Input type ="radio" name="workgroup" value="Agreenordisagree"/&gt;Neither Agree nor Disagree&lt;br/&gt;
&lt;Input type ="radio" name="workgroup" value="disagree"/&gt;Disagree&lt;br/&gt;

I have the opportunity to grow and develop at my company and/or elsewhere in UTC.
&lt;Input type ="radio" name="utc" value="agree"/&gt;Agree&lt;br/&gt;
&lt;Input type ="radio" name="utc" value="Agreenordisagree"/&gt;Neither Agree nor Disagree&lt;br/&gt;
&lt;Input type ="radio" name="utc" value="disagree"/&gt;Disagree&lt;br/&gt;

My job makes good use of my skills and abilities.
&lt;Input type ="radio" name="skills" value="agree"/&gt;Agree&lt;br/&gt;
&lt;Input type ="radio" name="skills" value="Agreenordisagree"/&gt;Neither Agree nor Disagree&lt;br/&gt;
&lt;Input type ="radio" name="skills" value="disagree"/&gt;Disagree&lt;br/&gt;

&lt;input name="Operation12" type="submit" value="submit" /&gt;
&lt;input name="Operation13" type="submit" value="back" /&gt;



&lt;/form&gt;

&lt;/body&gt;

&lt;/html&gt;

&lt;?php
session_start();
include 'classperson.php';

if($_POST['Operation1'])
{
$_SESSION['location'] = $location;
$_SESSION['location'] = $_POST['location'];
echo "Please save the link inorder to continue your survey http://bonnie/~jnagesh/SampleSurvey/OOPS/oopspage2.php";
}

else if($_POST['Operation2'])
{
$_SESSION['location'] = $location;
$_SESSION['location'] = $_POST['location'];
include "oopspage2.php";
}


elseif($_POST['Operation3'])

{
$_SESSION['effective'] = $effective;
$_SESSION['effective'] = $_POST['effective'];
$_SESSION['training'] = $training;
$_SESSION['training'] = $_POST['training'];
$_SESSION['treated'] = $treated;
$_SESSION['treated'] = $_POST['treated'];
$_SESSION['effort'] = $effort;
$_SESSION['effort'] = $_POST['effort'];
echo "Please save the link inorder to continue your survey http://bonnie/~jnagesh/SampleSurvey/OOPS/oopspage3.php";

}

elseif($_POST['Operation4'])
{
$_SESSION['effective'] = $effective;
$_SESSION['effective'] = $_POST['effective'];
$_SESSION['training'] = $training;
$_SESSION['training'] = $_POST['training'];
$_SESSION['treated'] = $treated;
$_SESSION['treated'] = $_POST['treated'];
$_SESSION['effort'] = $effort;
$_SESSION['effort'] = $_POST['effort'];
include "oopspage3.php";
}

elseif($_POST['Operation5'])
{
$_SESSION['location'] = $location;
$_SESSION['location'] = $_POST['location'];
include "oopspage1.php";
}

elseif($_POST['Operation6'])
{
$_SESSION['information'] = $information;
$_SESSION['information'] = $_POST['information'];
$_SESSION['recognition'] = $recognition;
$_SESSION['recognition'] = $_POST['recognition'];
$_SESSION['valued'] = $valued;
$_SESSION['valued'] = $_POST['valued'];
$_SESSION['supervisor'] = $supervisor;
$_SESSION['supervisor'] = $_POST['supervisor'];
echo "Please save the link inorder to continue your survey http://bonnie/~jnagesh/SampleSurvey/OOPS/oopspage4.php";

}

elseif($_POST['Operation7'] )
{
$_SESSION['information'] = $information;
$_SESSION['information'] = $_POST['information'];
$_SESSION['recognition'] = $recognition;
$_SESSION['recognition'] = $_POST['recognition'];
$_SESSION['valued'] = $valued;
$_SESSION['valued'] = $_POST['valued'];
$_SESSION['supervisor'] = $supervisor;
$_SESSION['supervisor'] = $_POST['supervisor'];
include "oopspage4.php";
}

elseif($_POST['Operation8'])
{
include "oopspage2.php";
}

elseif($_POST['Operation9'])
{
$_SESSION['informed'] = $informed;
$_SESSION['informed'] = $_POST['informed'];
$_SESSION['job'] = $job;
$_SESSION['job'] = $_POST['job'];
$_SESSION['treats'] = $treats;
$_SESSION['treats'] = $_POST['treats'];
$_SESSION['satisfy'] = $satisfy;
$_SESSION['satisfy'] = $_POST['satisfy'];
echo "Please save the link inorder to continue your survey http://bonnie/~jnagesh/SampleSurvey/OOPS/oopspage5.php";

}

elseif($_POST['Operation10'])
{
$_SESSION['informed'] = $informed;
$_SESSION['informed'] = $_POST['informed'];
$_SESSION['job'] = $job;
$_SESSION['job'] = $_POST['job'];
$_SESSION['treats'] = $treats;
$_SESSION['treats'] = $_POST['treats'];
$_SESSION['satisfy'] = $satisfy;
$_SESSION['satisfy'] = $_POST['satisfy'];
include "oopspage5.php";
}
elseif($_POST['Operation11'])
{
include "oopspage3.php";
}

elseif($_POST['Operation12'])
{
$con = mysql_connect("localhost","cgiadmin","cgi");
if (!$con)
 {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("j2", $con);

$person = new person1;
$person-&gt;set_location($_POST['location']);
$person-&gt;set_effective($_POST['effective']);
$person-&gt;set_training($_POST['training']);
$person-&gt;set_treated($_POST['treated']);
$person-&gt;set_effort($_POST['effort']);
$person-&gt;set_information($_POST['information']);
$person-&gt;set_recognition($_POST['recognition']);
$person-&gt;set_valued($_POST['valued']);
$person-&gt;set_supervisor($_POST['supervisor']);
$person-&gt;set_informed($_POST['informed']);
$person-&gt;set_job($_POST['job']);
$person-&gt;set_treats($_POST['treats']);
$person-&gt;set_satisfy($_POST['satisfy']);
$person-&gt;set_workgroup($_POST['workgroup']);
$person-&gt;set_utc($_POST['utc']);
$person-&gt;set_skills($_POST['skills']);


$sql="INSERT INTO bigsurvey(location, effective, training , treated , effort, information , recognition,valued,supervisor,informed,job,treats,satisfy,workgroup,utc,skills)
VALUES
('$_SESSION[location]','$_SESSION[effective]','$_SESSION[training]','$_SESSION[treated]','$_SESSION[effort]','$_SESSION[information]','$_SESSION[recognition]','$_SESSION[valued]','$_SESSION[supervisor]','$_SESSION[informed]','$_SESSION[job]','$_SESSION[treats]','$_SESSION[satisfy]','".$person-&gt;get_workgroup()."','".$person-&gt;get_utc()."','".$person-&gt;get_skills()."')";
if (!mysql_query($sql,$con))
  {
    die('Error: ' . mysql_error());
  }
echo "Thanks for taking the survey .";
mysql_close($con);

}
elseif($_POST['Operation13'])
{
include "oopspage4.php";
}
?&gt;
</code></pre>

<p>My question is , Is this the proper way to do or create a form using Object Oriented concept in php ? Or should I create any more objects or make any changes ?</p>

<p>I tried to include the file classperson.php on all the pages but I get an error when I use the next button . </p>

<p>Thanks in advance</p>
