Jump to content

PHP coding


JustinHamilton

Recommended Posts

hello, I am hoping someone can help me out with my assignment, I had to create a 3 page forum and at the end of the forum I have to include a summary page that displays the data using session variables the website url is http://host.macombserver.net/~hamiltonj858/itwp2750/project4/personal.php

 

Personal.php

 

<?php 
session_start();
require('class_info.php');
?>
<!DOCTYPE html>
 
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>professional Conference</title>
</head>
<body>
<?php 
if(isset($_POST['Next'])){
$multiform = new multiform();
$multiform->getPersonal();
echo $_SESSION['first']; 
}
?>
<a href="http://host.macombserver.net/~hamiltonj858/itwp2750/home.html">Back to student homepage.</a>
<h2>Personal Information</h2>
<form action="company.php" name="personal" method="post">
FirstName: <input type="text" name="first" /><br />
LastName: <input type="text" name="last" /><br />
Address: <input type="text" name="address" /><br />
City: <input type="text" name="city" /><br />
State: <input type="text" name="state" /><br />
Zip: <input type="text" name="zip" /><br />
Phone Number: <input type="text" name="phone" /><br />
Email: <input type="text" name="email" /><br />
<input type="submit" name="Next" value="Next" />
<input type="reset" name="start_over" value="Start Over" /><br />
</form>
 
<a href="http://validator.w3.org/check?uri=referer" title="HTML5 Validation">HTML5 Validation</a>
 
</html>
 
 
Company.php
 
<?php 
session_start();
require('class_info.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>professional Conference</title>
</head>
<body>
<?php 
if(isset($_POST['Next'])){
$multiform = new multiform();
$multiform->getCompany();
}
?>
<a href="http://host.macombserver.net/~hamiltonj858/itwp2750/home.html">Back to student homepage.</a>
<h2>Company Information</h2>
<form action="seminar.php" name="company_info" method="get">
Company Name: <input type="text" name="company" /><br />
Address: <input type="text" name="co_address" /><br />
City: <input type="text" name="co_city" /><br />
State: <input type="text" name="co_state" /><br />
Zip: <input type="text" name="co_zip" /><br />
Phone Number: <input type="text" name="co_phone" /><br />
<input type="submit" name="Next" value="Next" />
<input type="submit" name="back" value="Back" />
<input type="submit" name="start_over" value="Start Over" /><br />
</form>
 
<a href="http://validator.w3.org/check?uri=referer" title="HTML5 Validation">HTML5 Validation</a>
 
</html>
 
Seminar.php
 
<?php 
session_start();
require('class_info.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>professional Conference</title>
</head>
<body>
<?php
if(isset($_POST['Next'])){
$multiform = new multiform();
$multiform->getSeminar();
}
?>
<a href="http://host.macombserver.net/~hamiltonj858/itwp2750/home.html">Back to student homepage.</a>
<h2>Seminars</h2>
<form action="summary.php" name="seminars" method="post">
<input type="radio" name="javascript_seminar" value="JavaScript">JavaScript<br />
<input type="radio" name="php_seminar" value="PHP">PHP<br />
<input type="radio" name="mysql_seminar" value="MYSQL">MYSQL<br />
<input type="radio" name="apache_seminar" value="Apache">Apache<br />
<input type="radio" name="web_services_seminar" value="Web Services">Web Services<br />
<input type="submit" name="next" value="Next" />
<input type="submit" name="back" value="Back" />
<input type="submit" name="start_over" value="Start Over" /><br />
</form>
 
<a href="http://validator.w3.org/check?uri=referer" title="HTML5 Validation">HTML5 Validation</a>
</body>
 
</html>
 
Summary.php
 
<?php 
session_start();
require('class_info.php');
$multiform = new multiform();
 
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>professional Conference</title>
</head>
<body>
<a href="http://host.macombserver.net/~hamiltonj858/itwp2750/home.html">Back to student homepage.</a>
<h2>Summary</h2>
<form action="" method="post">
<h2><a href="personal.php">Personal</a></h2>
<?php 
$multiform->getPersonal();
 
?>
<h2><a href="company.php">Company</a></h2>
<?php 
$multiform->getCompany();
?>
<h2><a href="seminar.php">Seminar</a></h2>
<?php
$multiform->getSeminar();
?>
 
<a href="http://validator.w3.org/check?uri=referer" title="HTML5 Validation">HTML5 Validation</a>
</body>
 
</html>
 
Class_info.php
 
class multiform{
 
public function __construct(){
$this->first = $_SESSION['first'];
}
public function getPersonal(){
$First=$_SESSION['first']= $_POST['first'];
$_SESSION['last']= $_POST['last'];
$_SESSION['address']= $_POST['address'];
$_SESSION['state']= $_POST['state'];
$_SESSION['zip']= $_POST['zip'];
$_SESSION['phone']= $_POST['phone'];
$_SESSION['email']= $_POST['email'];
echo $First;
 
 
}
 
public function getCompany(){
$_SESSION['company']= $_POST['company'];
$_SESSION['co_address']= $_POST['co_address'];
$_SESSION['co_city']= $_POST['co_city'];
$_SESSION['co_state']= $_POST['co_state'];
$_SESSION['co_zip']= $_POST['co_zip'];
$_SESSION['co_phone']= $_POST['co_phone'];
 
echo $_SESSION['company'];
 
}
 
public function getSeminar(){
$_SESSION['javascript_seminar']= $_POST['javascript_seminar'];
$_SESSION['php_seminar']= $_POST['php_seminar'];
$_SESSION['mysql_seminar']= $_POST['mysql_seminar'];
$_SESSION['apache_seminar']= $_POST['apache_seminar'];
$_SESSION['web_services_seminar']= $_POST['web_services_seminar'];
 
echo $_SESSION['javascript_seminar'];
}
}
?>

 

Link to comment
Share on other sites

Your methods are just ridiculous. Stop creating a bunch of variables for nothing. The whole Class_info.php need to be thrown in the trash. It is just a container for a bunch of variables for nothing.

 

You have an HTML5 document yet you are using XHTML tags.

Edited by benanamen
Link to comment
Share on other sites

presumably, before this assignment, you had assignments leading up to having a single form and the form processing code for it, hopefully on a single page, so that you weren't duplicating code and you could display any validation errors when you re-displayed the same form?

 

this assignment, rather than just repeating that logic three times in separate files and stepping between the files, should be more about implementing this all on a single page, which would eliminate all the triplicated logic and html markup. when you move from one form to the next, you would just submit a hidden 'step' value with the form data. the code on a single page would use the step value to control what the page does.

 

you can produce previous/next step form buttons (like pagination) to let the visitor move between steps. if not on the first step, you would display a previous button. if not on the last step, you would display a next button. if on the last step, the next button would become the final submit button. the form processing code would use previous/next input to modify the step value if the submitted form data is valid (you would stay on the same step number if the data isn't valid.)

 

the form processing code would also use the submitted step value to control what it does. the submitted step value would tell the form processing code which set of inputs it should expect. the code would validate the input data and if the step is not the final form submission, store the validated data in a session variable (i would use the step number as a sub-array key for store the data from each step.)  forget about trying to use an OOP class for any part of this, get the program logic to work first. if the submitted data is from the final form submission, after you validate the inputs, use all the submitted data for whatever purpose you need.

Edited by mac_gyver
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.