Online Course Survey Use PHP for the Course Survey with three forms and a report
ID: 3757759 • Letter: O
Question
Online Course Survey
Use PHP for the Course Survey with three forms and a report as follows.
Create a folder called HW4 to contain your files
HW4 is due by end of class 10/29
1. The first form is a welcome page, with greeting message and input boxes for the student’s name, gender (selection from Male and Female), grade (selection from freshman, …), and course number (text box for CS489, MAT172, …).
2. The second form is the survey page, with at least five made-up questions for evaluating the course – at least four selections from (strongly agree, agree, not agree, not available) and one text area for more comments.
3. The last page concludes the user’s information (name, gender, grade, and course), the survey results, and the a thank you.
4. This should all be stored in a database and a report page created to output the survey results in a tabled list.
5. Check the submitted fields for valid data, apostrophes, and such...
6. 5 surveys worth or information should be entered into the database. So take the survey to test and enter information at least 5 times. Try to break it.
7. The option to delete a survey should be added to each resulting row returned. So that if john Smith submits a survey, I should be able to delete John Smith's results.
Explanation / Answer
CODE :
// Welcome page
<?php
// Greetings
if(date('G') >= 0 && date('G') <18)
{
echo 'Good Morning';
}
else {
echo 'Good Evening';
}
?>
<?php
echo "creating database ";
try {
$dbh = new PDO('sqlite:voting.db');
$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$dbh->exec('
CREATE TABLE student (
NAME varchar(32) NOT NULL,
GENDER varchar(32) NOT NULL,
GRADE varchar(32) NOT NULL,
COURSENO integer NOT NULL,
PRIMARY KEY (NAME, GENDER, GRADE))
');
}
catch(PDOException $e) {
echo "ERROR!!: $e";
exit;
}
echo "db created successfully.";
?>
//Survey page
<?php
include('webPoll.class.php');
webPoll::vote();
?>
$a = new webPoll(array(
'What subjects would you like to learn more about?',
'HTML & CSS',
'JavaScript',
'JS Frameworks (jQuery, etc)',
'Ruby/Ruby on Rails',
'PHP',
'mySQL'));
$b = new webPoll(array(
'What is your question?',
'Don't have one',
'Why?',
'When?',
'Where?'));
// User's information
<?php
echo "creating database ";
try {
$dbh = new PDO('sqlite:voting.db');
$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$dbh->exec('
CREATE TABLE user's_info (
NAME varchar(32) NOT NULL,
GENDER varchar(32) NOT NULL,
GRADE varchar(32) NOT NULL,
COURSENO integer NOT NULL,
PRIMARY KEY (NAME, GENDER, GRADE))
');
}
catch(PDOException $e) {
echo "ERROR!!: $e";
exit;
}
echo "db created successfully.";
?>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.