classperson.phpという名前のファイルを作成し、すべての変数を宣言しました。
<?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->location=$new_location;
}
function get_location()
{
return $this->location;
}
function set_effective($new_effective)
{
$this->effective=$new_effective;
}
function get_effective()
{
return $this->effective;
}
function set_training($new_training)
{
$this->training=$new_training;
}
function get_training()
{
return $this->training;
}
function set_treated($new_treated)
{
$this->treated=$new_treated;
}
function get_treated()
{
return $this->treated;
}
function set_effort($new_effort)
{
$this->effort=$new_effort;
}
function get_effort()
{
return $this->effort;
}
function set_information($new_information)
{
$this->information=$new_information;
}
function get_information()
{
return $this->information;
}
function set_recognition($new_recognition)
{
$this->recognition=$new_recognition;
}
function get_recognition()
{
return $this->recognition;
}
function set_valued($new_valued)
{
$this->valued=$new_valued;
}
function get_valued()
{
return $this->valued;
}
function set_supervisor($new_supervisor)
{
$this->supervisor=$new_supervisor;
}
function get_supervisor()
{
return $this->supervisor;
}
function set_informed($new_informed)
{
$this->informed=$new_informed;
}
function get_informed()
{
return $this->informed;
}
function set_job($new_job)
{
$this->job=$new_job;
}
function get_job()
{
return $this->job;
}
function set_treats($new_treats)
{
$this->treats=$new_treats;
}
function get_treats()
{
return $this->treats;
}
function set_satisfy($new_satisfy)
{
$this->satisfy=$new_satisfy;
}
function get_satisfy()
{
return $this->satisfy;
}
function set_workgroup($new_workgroup)
{
$this->workgroup=$new_workgroup;
}
function get_workgroup()
{
return $this->workgroup;
}
function set_utc($new_utc)
{
$this->utc=$new_utc;
}
function get_utc()
{
return $this->utc;
}
function set_skills($new_skills)
{
$this->skills=$new_skills;
}
function get_skills()
{
return $this->skills;
}
}
?>
後で、このファイルをoopossurvey.phpに含めました。これは5ページのフォームです
コードを調べてください
<?php
session_start();
$session=session_id();
$_SESSION['session']=$session;
?>
<html>
<body>
<form action="oopssurvey.php" method="post">
Where do you work?<br/>
<Input type ="radio" name="location" value="USA" <?php if($_SESSION['location'] == 'USA') echo "checked='checked'" ?>/>In the United states<br/>
<Input type ="radio" name="location" value="India" <?php if($_SESSION['location'] == 'India') echo "checked='checked'" ?>/>Outside of the United states<br/>
<input name="Operation1" type="submit" value="saveandresume" />
<input name="Operation2" type="submit" value="next" />
</form>
</body>
</html>
<?php
session_start();
if($_SESSION['session']==$session)
{
$location=$_SESSION['location'];
}
else
{
$_SESSION['location'] = $_POST['location'];
}
?>
<html>
<body>
<form action="oopssurvey.php" method="post">
In my work group, we are actively involved in making our work processes more effective and efficient (simpler, faster, etc.) using ACE.<br/>
<Input type ="radio" name="effective" value="Agree"/>Agree<br/>
<Input type ="radio" name="effective" value="Agreenordisagree"/>Neither Agree nor Disagree<br/>
<Input type ="radio" name="effective" value="disagree"/>Disagree<br/>
I have received the training I need to understand and implement ACE in my work group.<br/>
<Input type ="radio" name="training" value="Agree"/>Agree<br/>
<Input type ="radio" name="training" value="Agreenordisagree"/>Neither Agree nor Disagree<br/>
<Input type ="radio" name="training" value="disagree"/>Disagree<br/>
All employees at the company are treated fairly regardless of differences.<br/>
<Input type ="radio" name="treated" value="Agree"/>Agree<br/>
<Input type ="radio" name="treated" value="Agreenordisagree"/>Neither Agree nor Disagree<br/>
<Input type ="radio" name="treated" value="disagree"/>Disagree<br/>
Sufficient effort is made to get the opinions and thoughts of the people who work here.<br/>
<Input type ="radio" name="effort" value="Agree"/>Agree<br/>
<Input type ="radio" name="effort" value="Agreenordisagree"/>Neither Agree nor Disagree<br/>
<Input type ="radio" name="effort" value="disagree"/>Disagree<br/>
<input name="Operation3" type="submit" value="saveandresume" />
<input name="Operation4" type="submit" value="next" />
<input name="Operation5" type="submit" value="back" />
</form>
</body>
</html>
<?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'];
}
?>
<html>
<body>
<form action="oopssurvey.php" method="post">
How satisfied are you with the information you receive from management on what's going on in the company?<br/>
<Input type ="radio" name="information" value="agree"/>Agree<br/>
<Input type ="radio" name="information" value="Agreenordisagree"/>Neither Agree nor Disagree<br/>
<Input type ="radio" name="information" value="disagree"/>Disagree<br/>
How satisfied are you with the recognition you receive for doing a good job?<br/>
<Input type ="radio" name="recognition" value="agree"/>Agree<br/>
<Input type ="radio" name="recognition" value="Agreenordisagree"/>Neither Agree nor Disagree<br/>
<Input type ="radio" name="recognition" value="disagree"/>Disagree<br/>
I feel valued as an employee of the company.<br/>
<Input type ="radio" name="valued" value="agree"/>Agree<br/>
<Input type ="radio" name="valued" value="Agreenordisagree"/>Neither Agree nor Disagree<br/>
<Input type ="radio" name="valued" value="disagree"/>Disagree<br/>
My immediate supervisor does a good job of coaching/guiding me.<br/>
<Input type ="radio" name="supervisor" value="agree"/>Agree<br/>
<Input type ="radio" name="supervisor" value="Agreenordisagree"/>Neither Agree nor Disagree<br/>
<Input type ="radio" name="supervisor" value="disagree"/>Disagree<br/>
<input name="Operation6" type="submit" value="saveandresume" />
<input name="Operation7" type="submit" value="next" />
<input name="Operation8" type="submit" value="back" />
</form>
</body>
</html>
<?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'];
}
?>
<html>
<body>
<form action="oopssurvey.php" method="post">
I feel well informed about what is expected in my job.<br/>
<Input type ="radio" name="informed" value="agree"/>Agree<br/>
<Input type ="radio" name="informed" value="Agreenordisagree"/>Neither Agree nor Disagree<br/>
<Input type ="radio" name="informed" value="disagree"/>Disagree<br/>
Overall, how good a job do you feel is being done by your immediate supervisor<br/>
<Input type ="radio" name="job" value="agree"/>Agree<br/>
<Input type ="radio" name="job" value="Agreenordisagree"/>Neither Agree nor Disagree<br/>
<Input type ="radio" name="job" value="disagree"/>Disagree<br/>
My immediate supervisor treats me with respect and dignity.<br/>
<Input type ="radio" name="treats" value="agree"/>Agree<br/>
<Input type ="radio" name="treats" value="Agreenordisagree"/>Neither Agree nor Disagree<br/>
<Input type ="radio" name="treats" value="disagree"/>Disagree<br/>
How satisfied are you with your involvement in the decisions that affect your work?<br/>
<Input type ="radio" name="satisfy" value="agree"/>Agree<br/>
<Input type ="radio" name="satisfy" value="Agreenordisagree"/>Neither Agree nor Disagree<br/>
<Input type ="radio" name="satisfy" value="disagree"/>Disagree<br/>
<input name="Operation9" type="submit" value="saveandresume" />
<input name="Operation10" type="submit" value="next" />
<input name="Operation11" type="submit" value="back" />
</form>
</body>
</html>
<?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'];
}
?>
<html>
<body>
<form action="oopssurvey.php" method="post">
Day-to-day decisions and activities in my work group demonstrate that quality is a top priority.
<Input type ="radio" name="workgroup" value="agree"/>Agree<br/>
<Input type ="radio" name="workgroup" value="Agreenordisagree"/>Neither Agree nor Disagree<br/>
<Input type ="radio" name="workgroup" value="disagree"/>Disagree<br/>
I have the opportunity to grow and develop at my company and/or elsewhere in UTC.
<Input type ="radio" name="utc" value="agree"/>Agree<br/>
<Input type ="radio" name="utc" value="Agreenordisagree"/>Neither Agree nor Disagree<br/>
<Input type ="radio" name="utc" value="disagree"/>Disagree<br/>
My job makes good use of my skills and abilities.
<Input type ="radio" name="skills" value="agree"/>Agree<br/>
<Input type ="radio" name="skills" value="Agreenordisagree"/>Neither Agree nor Disagree<br/>
<Input type ="radio" name="skills" value="disagree"/>Disagree<br/>
<input name="Operation12" type="submit" value="submit" />
<input name="Operation13" type="submit" value="back" />
</form>
</body>
</html>
<?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->set_location($_POST['location']);
$person->set_effective($_POST['effective']);
$person->set_training($_POST['training']);
$person->set_treated($_POST['treated']);
$person->set_effort($_POST['effort']);
$person->set_information($_POST['information']);
$person->set_recognition($_POST['recognition']);
$person->set_valued($_POST['valued']);
$person->set_supervisor($_POST['supervisor']);
$person->set_informed($_POST['informed']);
$person->set_job($_POST['job']);
$person->set_treats($_POST['treats']);
$person->set_satisfy($_POST['satisfy']);
$person->set_workgroup($_POST['workgroup']);
$person->set_utc($_POST['utc']);
$person->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->get_workgroup()."','".$person->get_utc()."','".$person->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";
}
?>
私の質問は、これはphpでオブジェクト指向の概念を使用してフォームを作成または作成するための適切な方法ですか?または、さらにオブジェクトを作成するか、変更を加える必要がありますか?
すべてのページにclassperson.phpファイルを含めようとしましたが、次のボタンを使用するとエラーが発生します。
前もって感謝します