Please answer the following questions:

" ."

Please answer all five questions before you submit. Thank you.

"); print_end(); } if(isset($_GET) && (! isset($_GET['q_1']))) { print_form("

Please answer the following questions:

" ."

Please be sure to answer ALL questions before you submit. Thank you.

"); print_end(); } if(isset($_GET) && (! isset($_GET['q_2']))) { print_form("

Please answer the following questions:

" ."

Please be sure to answer ALL questions before you submit. Thank you.

"); print_end(); } if(isset($_GET) && (! isset($_GET['q_3']))) { print_form("

Please answer the following questions:

" ."

Please be sure to answer ALL questions before you submit. Thank you.

"); print_end(); } if(isset($_GET) && (! isset($_GET['q_4']))) { print_form("

Please answer the following questions:

" ."

Please be sure to answer ALL questions before you submit. Thank you.

"); print_end(); } if(isset($_GET) && (! isset($_GET['q_5']))) { print_form("

Please answer the following questions:

" ."

Please be sure to answer ALL questions before you submit. Thank you.

"); print_end(); } if(isset($_GET) && (isset($_GET['submit']))) { if (!mysqli_select_db($link, 'ggraeper')) { die('Could not select database: ' . mysqli_error()); } $result = mysqli_query($link, "SELECT * FROM survey_responses WHERE 1"); $num=mysqli_num_rows($result); print "
\n"; print "

Thank you for your response.

\n"; print "

" ."Total Respondents = " . $num . "

\n
"; date_default_timezone_set('America/New_York'); $time=date("U"); $ip='127.0.0.1'; if(isset($_SERVER['REMOTE_ADDR'])){ $ip=$_SERVER['REMOTE_ADDR']; if(isset($_GET['q_1']) && $response=$_GET['q_1']) { $q_1=$response; if (!mysqli_select_db($link, 'ggraeper')) { die('Could not select database: ' . mysqli_error()); } $ques_id = mysqli_query($link, "SELECT ques_id FROM survey_questions WHERE ques_id='1'"); $ques_id_GET = mysqli_fetch_assoc($ques_id); $ques = mysqli_query($link, "SELECT ques_content FROM survey_questions WHERE ques_id='1'"); $ques_get = mysqli_fetch_assoc($ques); print "
"; print $ques_id_GET['ques_id'] . ".) " . $ques_get['ques_content']; print "
"; print "
"; if($response == 5){ $ans = mysqli_query($link, "SELECT answer_1 FROM survey_questions WHERE ques_id='1'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_1']. ".\"\n" ; print "
"; } if($response == 4){ $ans = mysqli_query($link, "SELECT answer_2 FROM survey_questions WHERE ques_id='1'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_2']. ".\"\n" ; print ""; } if($response == 3){ $ans = mysqli_query($link, "SELECT answer_3 FROM survey_questions WHERE ques_id='1'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_3']. ".\"\n" ; print ""; } if($response == 2){ $ans = mysqli_query($link, "SELECT answer_4 FROM survey_questions WHERE ques_id='1'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_4']. ".\"\n" ; print ""; } if($response == 1){ $ans = mysqli_query($link, "SELECT answer_5 FROM survey_questions WHERE ques_id='1'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_5']. ".\"\n" ; print ""; } if (!mysqli_select_db($link, 'ggraeper')) { die('Could not select database: ' . mysqli_error()); } $result = mysqli_query($link, "SELECT * FROM survey_responses WHERE 1"); $num=mysqli_num_rows($result); $your_response = mysqli_query($link, "SELECT * FROM survey_responses WHERE value_1=$response"); $num_response=mysqli_num_rows($your_response)+1; $percent_response=number_format(($num_response / $num)*100); print "
"; print "Since the survey commenced, " . "" . $percent_response . "% " . "" . "of all respondents have selected the same answer you did."; print "
"; print "

"; } } if(isset($_GET['q_2']) && $response=$_GET['q_2']) { $q_2=$response; $ques_id = mysqli_query($link, "SELECT ques_id FROM survey_questions WHERE ques_id='2'"); $ques_id_GET = mysqli_fetch_assoc($ques_id); $ques = mysqli_query($link, "SELECT ques_content FROM survey_questions WHERE ques_id='2'"); $ques_get = mysqli_fetch_assoc($ques); print "
"; print $ques_id_GET['ques_id'] . ".) " . $ques_get['ques_content']; print "
"; print "
"; if($response == 5){ $ans = mysqli_query($link, "SELECT answer_1 FROM survey_questions WHERE ques_id='2'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_1']. ".\"\n" ; print "
"; } if($response == 4){ $ans = mysqli_query($link, "SELECT answer_2 FROM survey_questions WHERE ques_id='2'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_2']. ".\"\n" ; print ""; } if($response == 3){ $ans = mysqli_query($link, "SELECT answer_3 FROM survey_questions WHERE ques_id='2'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_3']. ".\"\n" ; print ""; } if($response == 2){ $ans = mysqli_query($link, "SELECT answer_4 FROM survey_questions WHERE ques_id='2'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_4']. ".\"\n" ; print ""; } if($response == 1){ $ans = mysqli_query($link, "SELECT answer_5 FROM survey_questions WHERE ques_id='2'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_5']. ".\"\n" ; print ""; } if (!mysqli_select_db($link, 'ggraeper')) { die('Could not select database: ' . mysqli_error()); } $result = mysqli_query($link, "SELECT * FROM survey_responses WHERE 1"); $num=mysqli_num_rows($result); $your_response = mysqli_query($link, "SELECT * FROM survey_responses WHERE value_2=$response"); $num_response=mysqli_num_rows($your_response)+1; $percent_response=number_format(($num_response / $num)*100); print "
"; print "Since the survey commenced, " . "" . $percent_response . "% " . "" . "of all respondents have selected the same answer you did."; print "
"; print "

"; } if(isset($_GET['q_3']) && $response=$_GET['q_3']) { $q_3=$response; $ques_id = mysqli_query($link, "SELECT ques_id FROM survey_questions WHERE ques_id='3'"); $ques_id_GET = mysqli_fetch_assoc($ques_id); $ques = mysqli_query($link, "SELECT ques_content FROM survey_questions WHERE ques_id='3'"); $ques_get = mysqli_fetch_assoc($ques); print "
"; print $ques_id_GET['ques_id'] . ".) " . $ques_get['ques_content']; print "
"; print "
"; if($response == 5){ $ans = mysqli_query($link, "SELECT answer_1 FROM survey_questions WHERE ques_id='3'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_1']. ".\"\n" ; print "
"; } if($response == 4){ $ans = mysqli_query($link, "SELECT answer_2 FROM survey_questions WHERE ques_id='3'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_2']. ".\"\n" ; print ""; } if($response == 3){ $ans = mysqli_query($link, "SELECT answer_3 FROM survey_questions WHERE ques_id='3'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_3']. ".\"\n" ; print ""; } if($response == 2){ $ans = mysqli_query($link, "SELECT answer_4 FROM survey_questions WHERE ques_id='3'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_4']. ".\"\n" ; print ""; } if($response == 1){ $ans = mysqli_query($link, "SELECT answer_5 FROM survey_questions WHERE ques_id='3'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_5']. ".\"\n" ; print ""; } if (!mysqli_select_db($link, 'ggraeper')) { die('Could not select database: ' . mysqli_error()); } $result = mysqli_query($link, "SELECT * FROM survey_responses WHERE 1"); $num=mysqli_num_rows($result); $your_response = mysqli_query($link, "SELECT * FROM survey_responses WHERE value_3=$response"); $num_response=mysqli_num_rows($your_response)+1; $percent_response=number_format(($num_response / $num)*100); print "
"; print "Since the survey commenced, " . "" . $percent_response . "% " . "" . "of all respondents have selected the same answer you did."; print "
"; print "

"; } if(isset($_GET['q_4']) && $response=$_GET['q_4']) { $q_4=$response; $ques_id = mysqli_query($link, "SELECT ques_id FROM survey_questions WHERE ques_id='4'"); $ques_id_GET = mysqli_fetch_assoc($ques_id); $ques = mysqli_query($link, "SELECT ques_content FROM survey_questions WHERE ques_id='4'"); $ques_get = mysqli_fetch_assoc($ques); print "
"; print $ques_id_GET['ques_id'] . ".) " . $ques_get['ques_content']; print "
"; print "
"; if($response == 5){ $ans = mysqli_query($link, "SELECT answer_1 FROM survey_questions WHERE ques_id='4'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_1']. ".\"\n" ; print "
"; } if($response == 4){ $ans = mysqli_query($link, "SELECT answer_2 FROM survey_questions WHERE ques_id='4'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_2']. ".\"\n" ; print ""; } if($response == 3){ $ans = mysqli_query($link, "SELECT answer_3 FROM survey_questions WHERE ques_id='4'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_3']. ".\"\n" ; print ""; } if($response == 2){ $ans = mysqli_query($link, "SELECT answer_4 FROM survey_questions WHERE ques_id='4'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_4']. ".\"\n" ; print ""; } if($response == 1){ $ans = mysqli_query($link, "SELECT answer_5 FROM survey_questions WHERE ques_id='4'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_5']. ".\"\n" ; print ""; } if (!mysqli_select_db($link, 'ggraeper')) { die('Could not select database: ' . mysqli_error()); } $result = mysqli_query($link, "SELECT * FROM survey_responses WHERE 1"); $num=mysqli_num_rows($result); $your_response = mysqli_query($link, "SELECT * FROM survey_responses WHERE value_4=$response"); $num_response=mysqli_num_rows($your_response)+1; $percent_response=number_format(($num_response / $num)*100); print "
"; print "Since the survey commenced, " . "" . $percent_response . "% " . "" . "of all respondents have selected the same answer you did."; print "
"; print "

"; } if(isset($_GET['q_5']) && $response=$_GET['q_5']) { $q_5=$response; $ques_id = mysqli_query($link, "SELECT ques_id FROM survey_questions WHERE ques_id='5'"); $ques_id_GET = mysqli_fetch_assoc($ques_id); $ques = mysqli_query($link, "SELECT ques_content FROM survey_questions WHERE ques_id='5'"); $ques_get = mysqli_fetch_assoc($ques); print "
"; print $ques_id_GET['ques_id'] . ".) " . $ques_get['ques_content']; print "
"; print "
"; if($response == 5){ $ans = mysqli_query($link, "SELECT answer_1 FROM survey_questions WHERE ques_id='5'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_1']. ".\"\n" ; print "
"; } if($response == 4){ $ans = mysqli_query($link, "SELECT answer_2 FROM survey_questions WHERE ques_id='5'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_2']. ".\"\n" ; print ""; } if($response == 3){ $ans = mysqli_query($link, "SELECT answer_3 FROM survey_questions WHERE ques_id='5'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_3']. ".\"\n" ; print ""; } if($response == 2){ $ans = mysqli_query($link, "SELECT answer_4 FROM survey_questions WHERE ques_id='5'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_4']. ".\"\n" ; print ""; } if($response == 1){ $ans = mysqli_query($link, "SELECT answer_5 FROM survey_questions WHERE ques_id='5'"); $ans_get = mysqli_fetch_assoc($ans); print "Your response was \"" . $ans_get['answer_5']. ".\"\n" ; print ""; } if (!mysqli_select_db($link, 'ggraeper')) { die('Could not select database: ' . mysqli_error()); } $result = mysqli_query($link, "SELECT * FROM survey_responses WHERE 1"); $num=mysqli_num_rows($result); $your_response = mysqli_query($link, "SELECT * FROM survey_responses WHERE value_5=$response"); $num_response=mysqli_num_rows($your_response)+1; $percent_response=number_format(($num_response / $num)*100); print "
"; print "Since the survey commenced, " . "" . $percent_response . "% " . "" . "of all respondents have selected the same answer you did."; print "
"; print "

"; $response_submitted=$time.'_'.$ip; if (!mysqli_select_db($link, 'ggraeper')) { die('Could not select database: ' . mysqli_error()); } mysqli_query($link, "INSERT INTO ggraeper . survey_responses (responder_id, value_1, value_2, value_3, value_4, value_5) VALUES ('$response_submitted','$q_1','$q_2','$q_3','$q_4','$q_5')"); } } print_end(); function print_form ($greeting) { print "$greeting\n"; print "
\n"; print "
\n"; print ""; $link= mysqli_connect('localhost','ggraeper','foobar'); if (!$link) { die('Could not connect: ' . mysqli_error()); } if (!mysqli_select_db($link, 'ggraeper')) { die('Could not select database: ' . mysqli_error()); } $result = mysqli_query($link, "SELECT * FROM survey_questions WHERE 1"); while ($row = mysqli_fetch_array($result)) { print ""; print ""; print "\n"; print "\n"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "" ; print ""; print ""; print "" ; print ""; print ""; print "" ; print ""; print ""; print "" ; print ""; print ""; } print "
"; print $row['ques_id'] . "). " . $row['ques_content']; print "
"; print "\n"; print "\n"; print "
"; print "\n"; print "\n"; print "
"; print "\n"; print "\n"; print "
"; print "\n"; print "\n"; print "
"; print "\n"; print "\n"; print "
"; print "
"; print "
"; print "
"; print "
"; print "\n"; print "
\n"; print "
\n"; } function print_end () { print "
\n"; print "\n"; print "
\n"; print ""; print ""; // leave PHP here exit; } ?>