Davecachia Posted August 13, 2008 Share Posted August 13, 2008 Hey all, first post here 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. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 13, 2008 Share Posted August 13, 2008 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". Quote Link to comment Share on other sites More sharing options...
geudrik Posted August 13, 2008 Share Posted August 13, 2008 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.... Quote Link to comment Share on other sites More sharing options...
geudrik Posted August 13, 2008 Share Posted August 13, 2008 oh, and you need to assign a group to your radio buttons so that you can only click on at a time. As of now, I am able to select them all. Quote Link to comment Share on other sites More sharing options...
Davecachia Posted August 13, 2008 Author Share Posted August 13, 2008 Fixed. Thanks Quote Link to comment Share on other sites More sharing options...
Davecachia Posted August 13, 2008 Author Share Posted August 13, 2008 What I am wondering is: DO I use the HTML form to send values to the PHP page, to validate the answers and assign points (as well as determine if it made the cutoffs?) then send the finished product to the database Quote Link to comment Share on other sites More sharing options...
geudrik Posted August 13, 2008 Share Posted August 13, 2008 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. Quote Link to comment Share on other sites More sharing options...
Davecachia Posted August 13, 2008 Author Share Posted August 13, 2008 Is there any chance you could help me out by porting one of the questions to a PHP file and I can repeat the steps for the rest? I've never done this before and i'm abit confused. Quote Link to comment Share on other sites More sharing options...
geudrik Posted August 13, 2008 Share Posted August 13, 2008 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.... Quote Link to comment Share on other sites More sharing options...
Davecachia Posted August 13, 2008 Author Share Posted August 13, 2008 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. Quote Link to comment Share on other sites More sharing options...
Davecachia Posted August 13, 2008 Author Share Posted August 13, 2008 OK so I need to use the PHP POST command to send the data from my HTML to my PHP. When the data gets into my PHP it will be validated and assessed. From there it will be scored. After scoring, stored then analyze. That sound about right? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 13, 2008 Share Posted August 13, 2008 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. Quote Link to comment Share on other sites More sharing options...
Davecachia Posted August 13, 2008 Author Share Posted August 13, 2008 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? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 13, 2008 Share Posted August 13, 2008 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. Quote Link to comment Share on other sites More sharing options...
Davecachia Posted August 13, 2008 Author Share Posted August 13, 2008 Thanks.. is there any way to +rep you or anything? Quote Link to comment Share on other sites More sharing options...
geudrik Posted August 13, 2008 Share Posted August 13, 2008 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. Quote Link to comment Share on other sites More sharing options...
Davecachia Posted August 14, 2008 Author Share Posted August 14, 2008 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> Quote Link to comment Share on other sites More sharing options...
Davecachia Posted August 14, 2008 Author Share Posted August 14, 2008 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 } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.