Jump to content

PHP Consult


Davecachia

Recommended Posts

Hey all, first post here  ;D

 

Here's my question:

 

My Professor has asked me to develop a web application for her. It is a survey it compliment some of her research.

 

Here is what I need it to do:

Have a user fill in a series of questions.

Questions answers are sent to a database and analyzed.

Answers are compared with marking scheme (points awarded are based on the size of the company)

 

SO:

 

Marking scheme - DYNAMIC: 3 different company sizes

COMPARATION - Company will be compared to criteria to see if they meet the cutoff value. If not, company recieves a 0 for score.

DATA storage - Stored to a database

DATA analyzation - Analyzation for the user to see where  they lost points and what they need to do better.

 

/discuss

www.dcncs.net/survey.html is the HTML form at the moment.

Link to comment
Share on other sites

Uhh, we're not here to write it for you, just to let you know.  Aside from that, just look up how to interact with databases in PHP, and the rest shouldn't be too hard at all.  Also, you have a grammar error or two on the form. ;) "you're" should be "your".

Link to comment
Share on other sites

It's good that you're starting with the form.  Once you have the form designed, you can create a table in your database that matches the info your want to submit.

 

Remember that the easiest way to store form data is in variables once it submitted.

 

$firstname = $_GET['firstname'];

 

And once you have your error checking completed, just plugging and chugging in a sql statement...

$sql = "INSERT INTO form (firstname, lastname, comments) VALUES ('$firstname', '$lastname', '$comments')";
mysql_query($sql) or die(mysql_error());

 

Form processing is really easy once you understand how the form elements interact with the php code and how the php knows which elements are what.  Google php form processing and you'll find something simple on how php communicates and handles submitted forms.

 

I hope this help, I wasn't totally sure of what your question was so....

 

:)

Link to comment
Share on other sites

You can, or you can use javascript to do so before the form is actually submitted.  That for you I think will make things more complicated. So use PHP to do so, but make sure that if there is an error, its displayed and the info they submitted is sent back to the form. That way if something is wrong, all the work they put into the form wasn't wasted and they don't get frusterated.

Link to comment
Share on other sites

Aren't you doing this for school?

 

Having me do it, even once, WILL NOT help you out in any way what so ever.  You won't wind up learning antyhing.  Snag a book on php man.

 

note: I already essentially wrote your SQL statment already....

Link to comment
Share on other sites

Aren't you doing this for school?

 

Having me do it, even once, WILL NOT help you out in any way what so ever.  You won't wind up learning antyhing.  Snag a book on php man.

 

note: I already essentially wrote your SQL statment already....

 

Storing isn't the issue yet. It's actually getting it into the PHP form so that I can validate and assign point values to the survey questions.

Link to comment
Share on other sites

Here, I'll outline it really quickly I guess.

 

1. Data is sent from form to PHP.

2. Data is validated inside of PHP using the proper methods and returned if it's not good so they can edit it.

3. Data is then escaped for use inside the database.

4. On the page where you want to view the data, the analysis happens.

 

It's actually pretty simple when you get down to the basics of it.

Link to comment
Share on other sites

Here, I'll outline it really quickly I guess.

 

1. Data is sent from form to PHP.

2. Data is validated inside of PHP using the proper methods and returned if it's not good so they can edit it.

3. Data is then escaped for use inside the database.

4. On the page where you want to view the data, the analysis happens.

 

It's actually pretty simple when you get down to the basics of it.

 

Thats pretty much what I was hoping to hear.

Alright! So would you suggest I use the POST command, GET, or REQUEST to send the data to the PHP?

Link to comment
Share on other sites

Here, I'll outline it really quickly I guess.

 

1. Data is sent from form to PHP.

2. Data is validated inside of PHP using the proper methods and returned if it's not good so they can edit it.

3. Data is then escaped for use inside the database.

4. On the page where you want to view the data, the analysis happens.

 

It's actually pretty simple when you get down to the basics of it.

 

Thats pretty much what I was hoping to hear.

Alright! So would you suggest I use the POST command, GET, or REQUEST to send the data to the PHP?

 

You'd use the POST method.  Don't ever use REQUEST really because it's essentially a combination of GET, POST, and COOKIE, so you don't know where everything is coming from.  Use the proper method, which is in this case, POST.

Link to comment
Share on other sites

So you know...

 

$_GET['name']

 

This piece is telling php to GET what ever data is being posted from a field NAMED 'name'

 

when you post the form, your button also has to have a name, so when you set your if statement up.. it would look like...

 

if( isset( $_POST['process_form'] ) )
{
   $name = $_GET['name'];
}

 

Now, that last bit of code... tell me how it work.

Link to comment
Share on other sites

OK i'm back.

 

I've successfully moved values from HTML form into my PHP document.

 

I need a hand with the validation.. and reading the data into variables.

Here is my code:

<!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=iso-8859-1" />
<title>Survey</title>
</head>

<body>
<p>Impact of Training Form:</p>

//*** READ IN DATA FROM HTML FORM *** //

Name: <?php echo$_POST["CompanyName"]; ?>.<br />
Industry Type: <?php echo$_POST["IndustryType"]; ?>.<br />
Company Size: <?php echo$_POST["CompanySize"]; ?>.<br />
ClassRoom Training: <?php echo$_POST["ClassRoomTraining"]; ?>.<br />
<br>
ClassRoom Options
Orientation: <?php echo$_POST["ClassRoomOrientation"]; ?>.<br />
Managerial or Supervisory Training: <?php echo$_POST["ClassRoomManagerialOrSupervisoryTraining"]; ?>.<br />
Apprenticeship Training: <?php echo$_POST["ClassRoomApprenticeshipTraining"]; ?>.<br />
Computer Hardware Training: <?php echo$_POST["ClassRoomComputerHardware"]; ?>.<br />
Computer Software Training: <?php echo$_POST["ClassRoomComputerSoftware"]; ?>.<br />
Other office and non office equipment: <?php echo$_POST["ClassRoomOtherOffice"]; ?>.<br />
Classroom Decision and Problem Solving: <?php echo$_POST["ClassRoomGroupDecisionMaking"]; ?>.<br />
Classroom Team Building: <?php echo$_POST["ClassRoomTeamBuilding"]; ?>.<br />
Classroom Literacy or Numeracy: <?php echo$_POST["ClassRoomLiteracyOrNumeracy"]; ?>.<br />
<br>
Total Training Expenditure: <?php echo$_POST["TotalTrainingExpenditure"]; ?>.<br />
Trainers Salary: <?php echo$_POST["TrainersSalary"]; ?>.<br />
Trainees Salary: <?php echo$_POST["TraineesSalary"]; ?>.<br />
Vendor Contracts: <?php echo$_POST["ContractsToVendors"]; ?>.<br />
Direct Tuition: <?php echo$_POST["DirectTuition"]; ?>.<br />
Training Materials: <?php echo$_POST["TrainingMaterials"]; ?>.<br />
Travel or Living expenses: <?php echo$_POST["TravelOrLivingCosts"]; ?>.<br />
Overhead: <?php echo$_POST["Overhead"]; ?>.<br />
Other: <?php echo$_POST["Other"]; ?>.<br />
<br>
Work Place Orientation: <?php echo$_POST["WorkPlaceOrientation"]; ?>.<br />
Work Place Managerial or Supervisory: <?php echo$_POST["WorkPlaceManagerialOrSupervisoryTraining"]; ?>.<br />
Work Place Apprenticeship Training: <?php echo$_POST["WorkPlaceApprenticeshipTraining"]; ?>.<br />
Work Place Computer Hardware: <?php echo$_POST["WorkPlaceComputerHardware"]; ?>.<br />
Work Place Computer Software: <?php echo$_POST["WorkPlaceComputerSoftware"]; ?>.<br />
Work Place Other Office: <?php echo$_POST["WorkPlaceOtherOffice"]; ?>.<br />
Work Place Group Decision Making: <?php echo$_POST["WorkPlaceGroupDecisionMaking"]; ?>.<br />
Work Place Team Building: <?php echo$_POST["WorkPlaceTeamBuilding"]; ?>.<br />
Work Place Literacy and Numeracy: <?php echo$_POST["WorkPlaceLiteracyOrNumeracy"]; ?>.<br />
<br>
Total Amount of Employees: <?php echo$_POST["TotalAmountEmployees"]; ?>.<br />


</body>
</html>

Link to comment
Share on other sites

Let me know if I am on the right track here.

 

if( isset( $_POST['process_form'] ) )
{
   $CompanyName = $_GET['CompanyName'];
   $IndustryType = $_GET['IndustryType'];
   $CompanySize = $_GET['CompanySize'];
   $ClassRoomTraining = $_GET['ClassRoomTraining'];
   $ClassRoomOrientation = $_GET['ClassRoomOrientation'];
   $ClassRoomManagerialOrSupervisoryTraining = $_GET['ClassRoomManagerialOrSupervisoryTraining'];
   $ClassRoomApprenticeshipTraining = $_GET['ClassRoomApprenticeshipTraining'];
   $ClassroomComputerHardware = $_GET['ClassRoomComputerHardware'];
   $ClassroomComputerSoftware = $_GET['ClassRoomComputerSoftware'];
   $ClassroomOtherOffice = $_GET['ClassRoomotherOffice'];
   $ClassroomGroupDecisionMaking = $_GET['ClassRoomGroupDecisionMaking'];
   $ClassroomTeamBuilding = $_GET['ClassRoomTeamBuilding'];
   $ClassroomLiteracyOrNumeracy = $_GET['ClassRoomLiteracyOrNumeracy'];
   $TotalTrainingExpenditure = $_GET['TotalTrainingExpenditure'];
   $TrainersSalary =$_GET['TrainersSalary'];
   ..... will finish later
    
   
}

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.