KaffeKarsK Skrevet 20. november 2008 Del Skrevet 20. november 2008 (endret) Hei, Prøver å legge inn bilder i denne filen: <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <?php /**************************************************** // Dodo's Quiz Script // Copyrighted by Ying Zhang // http://regretless.com/scripts // No redistribution without authorization // Script released under linkware // that means LINK ME if you use it for your website /****************************************************/ /******************************************************************************** Remember if you name this file quiz_1.php it will be quiz no. 1! You will have to call this script by using quiz.php?n=1 *********************************************************************************/ // Would you like to get get an email when someone takes this particular quiz? $email_notify = 0; // 1 = yes 0 = no // if so $admin_email = "[email protected]"; // Your quiz question: $quiz_question = "Ser du forskjell på oppdrettslaks og villaks?"; // What you want your submit button to say? $submit_button = "Se resultatet"; // Your quiz description: $quiz_description = "Dette er en test som avgjør om du klarer å se forskjell på oppdrettslaks og villaks. Lykke til!"; // Do you want to make sure that all of your questions are answered before the results are calculated? $all_questions_answer = 1; // 1 = yes 0 = no // Now for each result, give it a description. Please make sure you put \ in front your quotations or you will get parse error! // Put them as the result name => result description // For example: "not_the_one" => "You are definitely not the one for Dodo. Too bad "; // WARNING: it's always possible to get the same two results so watch the order of these. $results_array = array( 1 => "<div class=\"header\">Ordinær</div><div class=\"just\">Du er ikke helt der enda <br /><br />Du liter med å se forskjell på oppdrettslaks som har vært fri lenge, men de åpenbare tar du.</div>", 2 => "<div class=\"header\">Ekspert</div><div class=\"just\">Dette kan du!<br /><br />Du kan virkelig se forskjell på oppdrettslaks og villaks. Uavhengig av tidsrommet fra den rømte, til den lå på land. Flott!</div>", 3 => "<div class=\"header\">Amatør</div><div class=\"just\">Du klarer virkelig ikke å se forskjell på oppdrettslaks og villaks. <br /><br /></div>", ); // Now your questions $questions_array = array( 1=> "Hva er den enkleste måten å skille oppdrettslaks og villaks?", 2=> "Som sportsfisker, vil det være mer kamp i villaksen eller oppdrettslaksen?", 3=> "Er dette oppdrettslaks eller villaks?", ); // your answers. MAKE SURE it's the same order as the questions. also gives which of the results is the answer corresponding to separated by the symbol |. One unique answer per line! $answers_array = array( HER 1=> "Fettfinnen|2 Fargen|3 Prikkene|1 Vekten|3 Kroken|3", OG HER 2=> "Ja|2 Avhengig av hvor lenge laksen har levd fritt|1 Nei|3", // above will print as answers // 1. Spring (sorta) // 2. Summer (not the one) // 3. Fall (the one) // 4. Winter (not the one) 3=> "Ja|2 Nei|3", // above will print as answers // 1. Spring (sorta) // 2. Summer (not the one) // 3. Fall (the one) // 4. Winter (not the one) /******************************************* I hope you get the idea now. Just add more if you have more questions. Make sure to change the index numbers. For example, the next one should begin with 3=> "blah|1 blah|2 blah|3", always end with a quotation and a comma! *******************************************/ ); ######### END OF QUIZ 1 DATA ################################################## ?> For å korte ned hvor jeg trenger, så lager jeg et lite utkast her: $answers_array = array HER VIL JEG LEGGE INN ET BILDE! 1=> "Fettfinnen|2 Fargen|3 Prikkene|1 Vekten|3 Kroken|3", HER VIL JEG OGSÅ LEGGE INN ET BILDE! 2=> "Ja|2 Avhengig av hvor lenge laksen har levd fritt|1 Nei|3", // above will print as answers // 1. Spring (sorta) // 2. Summer (not the one) // 3. Fall (the one) // 4. Winter (not the one) 3=> "Ja|2 Nei|3", // above will print as answers // 1. Spring (sorta) // 2. Summer (not the one) // 3. Fall (the one) // 4. Winter (not the one) Endret 20. november 2008 av KaffeKarsK Lenke til kommentar
ThomasQ Skrevet 20. november 2008 Del Skrevet 20. november 2008 (endret) <img> ? Endret 20. november 2008 av ThomasQ Lenke til kommentar
KaffeKarsK Skrevet 20. november 2008 Forfatter Del Skrevet 20. november 2008 <img> fungerer helt oppe på siden, men på denne delen av filen. Trenger virkelig hjelp til dette <img> fungerer helt oppe på siden, men på denne delen av filen. Trenger virkelig hjelp til dette Lenke til kommentar
ThomasQ Skrevet 20. november 2008 Del Skrevet 20. november 2008 ,"<img src=\"bildeling.png\">" ? Lenke til kommentar
KaffeKarsK Skrevet 20. november 2008 Forfatter Del Skrevet 20. november 2008 Parse error: syntax error, unexpected ',', expecting ')' in /home/utmarka/public_html/dodosquiz/dodosquiz/quiz_1.php on line 86 Får den feilen når jeg legger inn img koden lengre ned i filen. Lurer på om det er noen koder som gjør at jeg ikke får lov til å legge inn filen? Ser du/dere noe i filen som kan hindre det? Lenke til kommentar
ThomasQ Skrevet 20. november 2008 Del Skrevet 20. november 2008 Parse error: syntax error, unexpected ',', expecting ')' in /home/utmarka/public_html/dodosquiz/dodosquiz/quiz_1.php on line 86 Får den feilen når jeg legger inn img koden lengre ned i filen. Lurer på om det er noen koder som gjør at jeg ikke får lov til å legge inn filen? Ser du/dere noe i filen som kan hindre det? Legg den der det står "HER VIL JEG OGSÅ LEGGE INN ET BILDE!" Lenke til kommentar
KaffeKarsK Skrevet 20. november 2008 Forfatter Del Skrevet 20. november 2008 Når jeg legger inn kun dette: <img src="http://XXXnet/design/images/phocagallery/kilosorreter.jpg"> Denne koden fungerer forresten når jeg legger den inn helt oppe på siden.. så får jeg følgende feil: Parse error: syntax error, unexpected '<', expecting ')' in /home/utmarka/public_html/dodosquiz/dodosquiz/quiz_1.php on line 86 Lenke til kommentar
KaffeKarsK Skrevet 20. november 2008 Forfatter Del Skrevet 20. november 2008 (endret) Beklager, ThomasQ. Så ikke du hadde svart! Jeg har lagt den inn der. Slik ser et utkast ut nå: // your answers. MAKE SURE it's the same order as the questions. also gives which of the results is the answer corresponding to separated by the symbol |. One unique answer per line! $answers_array = array( <img src="http://www.utmarka.net/design/images/phocagallery/kilosorreter.jpg"> 1=> "Fettfinnen|2 Fargen|3 Prikkene|1 Vekten|3 Kroken|3", 2=> "Ja|2 Avhengig av hvor lenge laksen har levd fritt|1 Nei|3", // above will print as answers // 1. Spring (sorta) // 2. Summer (not the one) // 3. Fall (the one) // 4. Winter (not the one) 3=> "Ja|2 Nei|3", Og da får jeg følgende feil: Parse error: syntax error, unexpected '<', expecting ')' in /home/utmarka/public_html/dodosquiz/dodosquiz/quiz_1.php on line 73 Endret 20. november 2008 av KaffeKarsK Lenke til kommentar
ThomasQ Skrevet 20. november 2008 Del Skrevet 20. november 2008 Du gjør jo ikke som jeg sier.. Lenke til kommentar
KaffeKarsK Skrevet 20. november 2008 Forfatter Del Skrevet 20. november 2008 Du gjør jo ikke som jeg sier.. Har du ikke en feil i den koden? ,"<img src=\"bildeling.png\">" Må det ikke være: ," <img scr="/design/images/phocagallery/kilosorreter.jpg>" Evt, kan du skrive inn hele koden for meg, nå som du vet hvor filen ligger? Har lagt denne koden koden: ,"<img src=\"design\images\phocagallery\kilosorreter.jpg\">" Uten hell. Har også prøvd ," <img scr="/design/images/phocagallery/kilosorreter.jpg>" uten hell. Den er også lagt inn der det står: "HER VIL JEG LEGGE INN ET BILDE!" Lenke til kommentar
OISNOT Skrevet 20. november 2008 Del Skrevet 20. november 2008 (endret) 1. Dodo kunne ikke programmere i 2003. 2. Du har kvotert feil del av programmet. 3. Alle kan se ka som er riktig svar i kildekoden på websiden (html). 4. $answers_array = array( 1=> array( 'pic' => 'url', 'choices' => array( "Fettfinnen" =>2, "Fargen" => 3, "Prikkene" => 1, "Vekten" => 3, "Kroken" => 3, ), ), 2 => array( 'pic' => 'url2', 'choices' => array( "Ja" => 2, "Avhengig av hvor lenge laksen har levd fritt" => 1 "Nei" => 3, ), ), 3=> array( 'choices' => array( "Ja" => 2 "Nei" => 3, ), ), ); Bytt ut for($i = 1; $i <= count($questions_array); $i++) { echo "<div class=\"rings\">".$questions_array[$i]."</div>\n"; // find the answers $this_answers = explode("\n", $answers_array[$i]); // print the answers and modify the results echo "<div class=\"just\">\n"; for($k = 0; $k < count($this_answers); $k++) { $this_particular_answer = explode("|", $this_answers[$k]); echo "<label><input type=\"radio\" name=\"choices[".$i."]\" value=\"".trim($this_particular_answer[1])."\">".$this_particular_answer[0]."</label><br /> \n"; } echo "</div><br />\n"; //print_r($this_answers); } // end of for med foreach ($questions_array as $i => $question) { echo "<div class=\"rings\">". htmlentities($question)."</div>\n"; echo "<div class=\"just\">\n"; foreach ($this_answers[$i] as $col => $data) { if ($col == 'pic') { echo '<img src="'. $data . '" />'; } elseif ($col == 'choices') { foreach ($data as $choice => $k) { echo '<label><input type="radio" name="choices[' . $i . ']" value="' . htmlentities($k) . '" \>' . htmlentities($choice) . "</label><br /> \n"; } } } echo "</div><br />\n"; } Endret 20. november 2008 av OISNOT Lenke til kommentar
KaffeKarsK Skrevet 20. november 2008 Forfatter Del Skrevet 20. november 2008 Hei! Takk for at du har tatt deg tid til å hjelpe meg! Setter umåtelig stor pris på det! Har gjort alle endringen du sa, men nå får jeg opp dette: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/utmarka/public_html/dodosquiz/dodosquiz/quiz_1.php on line 88 På linje 88 står det: "Nei" => 3, Lenke til kommentar
KaffeKarsK Skrevet 20. november 2008 Forfatter Del Skrevet 20. november 2008 Nå ser quiz_1.php slik ut: <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <?php /**************************************************** // Dodo's Quiz Script // Copyrighted by Ying Zhang // http://regretless.com/scripts // No redistribution without authorization // Script released under linkware // that means LINK ME if you use it for your website /****************************************************/ /******************************************************************************** Remember if you name this file quiz_1.php it will be quiz no. 1! You will have to call this script by using quiz.php?n=1 *********************************************************************************/ // Would you like to get get an email when someone takes this particular quiz? $email_notify = 0; // 1 = yes 0 = no // if so $admin_email = "[email protected]"; // Your quiz question: $quiz_question = "Ser du forskjell på oppdrettslaks og villaks?"; // What you want your submit button to say? $submit_button = "Se resultatet"; // Your quiz description: $quiz_description = "Dette er en test som avgjør om du klarer å se forskjell på oppdrettslaks og villaks. Lykke til!"; // Do you want to make sure that all of your questions are answered before the results are calculated? $all_questions_answer = 1; // 1 = yes 0 = no // Now for each result, give it a description. Please make sure you put \ in front your quotations or you will get parse error! // Put them as the result name => result description // For example: "not_the_one" => "You are definitely not the one for Dodo. Too bad :("; // WARNING: it's always possible to get the same two results so watch the order of these. $results_array = array( 1 => "<div class=\"header\">Ordinær</div><div class=\"just\">Du er ikke helt der enda <br /><br />Du liter med å se forskjell på oppdrettslaks som har vært fri lenge, men de åpenbare tar du.</div>", 2 => "<div class=\"header\">Ekspert</div><div class=\"just\">Dette kan du!<br /><br />Du kan virkelig se forskjell på oppdrettslaks og villaks. Uavhengig av tidsrommet fra den rømte, til den lå på land. Flott!</div>", 3 => "<div class=\"header\">Amatør</div><div class=\"just\">Du klarer virkelig ikke å se forskjell på oppdrettslaks og villaks. <br /><br /></div>", ); // Now your questions $questions_array = array( 1=> "Hva er den enkleste måten å skille oppdrettslaks og villaks?", 2=> "Som sportsfisker, vil det være mer kamp i villaksen eller oppdrettslaksen?", 3=> "Er dette oppdrettslaks eller villaks?", ); // your answers. MAKE SURE it's the same order as the questions. also gives which of the results is the answer corresponding to separated by the symbol |. One unique answer per line! $answers_array = array( 1=> array( 'pic' => 'url', 'choices' => array( "Fettfinnen" =>2, "Fargen" => 3, "Prikkene" => 1, "Vekten" => 3, "Kroken" => 3, ), ), 2 => array( 'pic' => 'url2', 'choices' => array( "Ja" => 2, "Avhengig av hvor lenge laksen har levd fritt" => 1 "Nei" => 3, ), ), 3=> array( 'pic' = 'http://www.utmarka.net/design/images/phocagallery/kilosorreter.jpg 'choices' => array( "Ja" => 2 "Nei" => 3, ), ), ); ######### END OF QUIZ 1 DATA ################################################## ?> dodosquiz.php ser slik ut nå: ? /**************************************************** // Dodo's Quiz Script // Copyrighted by Ying Zhang // http://regretless.com/scripts // No redistribution without authorization // Script released under linkware // that means LINK ME if you use it for your website /****************************************************/ /*********************************************************** // With this script you should able to make multiple quizzes // Just call your quiz with its number. // For example: dodosquiz.php?n=1 will include your quiz_1.php // No changes below this unless you REALLY KNOW what you are // doing. /***********************************************************/ /************************************************************ // Email function added Jan 30, 2003 // Made it compatible with PHP5 April 1, 2008 /************************************************************/ if(!$_GET['n']) exit; require("quiz_".$_GET['n'].".php"); include("header.php"); if($_GET['action'] == "results") { $choices = $_POST['choices']; $total_choices = count($choices); if($total_choices == 0) { echo "<div class=\"rings\">Error</div><div class=\"just\">None of the questions is answered! Please <a href=\"java script:history.back(1)\">go back</a> and answer them!"; } else { if($all_questions_answer && ($total_choices != count($questions_array))) { echo "<div class=\"rings\">Error</div><div class=\"just\">You didn't answer all the questions. Please <a href=\"java script:history.back(1)\">go back</a> and answer them!"; footer(); include("footer.php"); exit; } /********************* MATH QUIZ RESULT **********************/ if($math_quiz) { // calculate the results // declare an array the same size as choices with only 0 $total_results = count($results_array); for($j=1; $j <= $total_results; $j++) { $int_results_array[$j]=0; } for($i=1; $i <= $total_choices; $i++) { $num = trim($choices[$i]); // if the quiz taker has choosen the correct answer if($num == $correct_result) $int_results_array[$correct_result]=$int_results_array[$correct_result]+1; } $max_value = max($int_results_array); // if max_value is the same as the total number of questoins if($max_value == count($questions_array)) { $right = 1; } if($right) $final_result=$results_array[$correct_result]; else { if($math_quiz_show_correct) { $total = count($questions_array); $final_result = $results_array[$math_quiz_show_correct_before]." It seems you have gotten <b>$max_value</b> out of $total correct.".$results_array[$math_quiz_show_correct_after]; } else { $final_result=$results_array[$wrong_result]; } } echo $final_result; email_admin($final_result); footer(); include("footer.php"); exit; } /********************* END OF THE MATH QUIZ **********************/ /********************* TYPE 2 QUIZ RESULT **********************/ if($quiz_2) { // test to make sure the level array is the same size as the result array if(count($level_array) != count($results_array)) { echo "<div class=\"rings\">Error</div><div class=\"just\">The quiz maker didn't provide valid info for this quiz. If you are the quiz maker, please make your level array the same size as your result array in order for the type 2 quiz to work!</div>"; footer(); include("footer.php"); exit; } // calculate the results $total_num_correct = 0; for($i=1; $i <= $total_choices; $i++) { $num = trim($choices[$i]); // if the quiz taker has choosen the correct answer if($num == $correct_result) $total_num_correct++; } // now $total_num_correct should contain how many problems did the quiz taker get right. if($total_num_correct <= $level_array[1]) { $final_result = $results_array[1]; echo $final_result; footer(); email_admin($final_result); include("footer.php"); exit; } $total_levels = count($level_array); for($j=1; $j < ($total_levels-1); $j++) { $k=$j+1; if(($total_num_correct > $level_array[$j]) && ($total_num_correct <= $level_array[$k])) { $final_result = $results_array[$k]; echo $final_result; footer(); email_admin($final_result); include("footer.php"); exit; } } // else the final result must the be the last $final_result = $results_array[count($results_array)]; echo $final_result; footer(); email_admin($final_result); include("footer.php"); exit; } /********************* END OF THE QUIZ II **********************/ // calculate the results // results array //print_r($results_array); // declare an array the same size as choices with only 0 $total_results = count($results_array); for($j=1; $j <= $total_results; $j++) { $int_results_array[$j]=0; } //print_r($choices); for($i=1; $i <= $total_choices; $i++) { $num = trim($choices[$i]); $int_results_array[$num]=$int_results_array[$num]+1; } //print_r($int_results_array); $max_value = max($int_results_array); $total_int_results_array = count($int_results_array); for($i=1; $i<=$total_int_results_array; $i++) { if($int_results_array[$i] == $max_value) { $max_key = $i; break; } } //echo "the max key is $max_key"; //print_r($int_results_array); //echo "max key is $max_key"; $final_result=$results_array[$max_key]; echo $final_result; } // end of else } // end of the result function function email_admin($final_result) { global $admin_email, $email_notify, $HTTP_USER_AGENT, $REMOTE_ADDR, $HTTP_REFERER, $quiz_question; // email admin if it's enabled if($email_notify) { if($final_result != "") { $final_email_result = str_replace("<div class=\"header\">", "", $final_result); $final_email_result = str_replace("<div class=\"just\">", "", $final_email_result); $final_email_result = str_replace("</div>", "\n\n", $final_email_result); $final_email_result = str_replace("<br />", "\n", $final_email_result); // get the quiz taker's info $date = date("Y-m-d H:i:s"); $ip = $_SERVER['REMOTE_ADDR']; $browser_info = $_SERVER['HTTP_USER_AGENT']; $host = gethostbyaddr($ip); $referer = $_SERVER['HTTP_REFERER']; // from info $from_info = " This is the result of the test taker: $final_email_result ------------------------------------------------------------------------------------------ IP: $ip HOST: $host Browser: $browser_info Time: $date Referred by: $referer ------------------------------------------------------------------------------------------"; $subject = "Someone has taken $quiz_question quiz"; //echo "in footer, trying to send mail: $admin_email, $final_result, $from_info, $subject"; mail($admin_email, $subject, $from_info, "From: Test_Taker"); } // end of if final result is not empty } // end of if } function footer() { echo "<div style=\"font-family: Verdana; font-size: 10px;\">Quiz made possible with <a href=\"http://regretless.com/scripts/\" target=\"_blank\">Dodo's Quiz Script</a></div>"; } // end of footer function if(!$_GET['action']) { echo "<div class=\"header\">".$quiz_question."</div>\n<div class=\"just\">".$quiz_description."</div>"; echo "<form action=\"dodosquiz.php?n=".$_GET['n']."&action=results\" method=\"post\">"; foreach ($questions_array as $i => $question) { echo "<div class=\"rings\">". htmlentities($question)."</div>\n"; echo "<div class=\"just\">\n"; foreach ($this_answers[$i] as $col => $data) { if ($col == 'pic') { echo '<img src="'. urlencode($data) . '" />'; } elseif ($col == 'choices') { foreach ($data as $choice => $k) { echo '<label><input type="radio" name="choices[' . $i . ']" value="' . htmlentities($k) . '" \>' . htmlentities($choice) . "</label><br /> \n"; } } } echo "</div><br />\n"; } echo "<input type=\"submit\" value=\"".$submit_button."\" class=\"form\"></form>"; } // end of if not action footer(); email_admin($final_result); include("footer.php"); ?> Er det noe feil? Lenke til kommentar
KaffeKarsK Skrevet 20. november 2008 Forfatter Del Skrevet 20. november 2008 Jeg fant ut at det manglet , bak: "Avhengig av hvor lenge laksen har levd fritt" => 1 og "Ja" => 2 La disse til og jeg får opp siden. Men der svaralternativene er, får jeg følgende feilmelding: Are you the one for Dodo? This is a quiz that finds out your compatibility with Dodo Have fun! What color does dodo like? Warning: Invalid argument supplied for foreach() in /home/utmarka/public_html/dodosquiz/dodosquiz/dodosquiz.php on line 248 What season does dodo like? Warning: Invalid argument supplied for foreach() in /home/utmarka/public_html/dodosquiz/dodosquiz/dodosquiz.php on line 248 What season does dodo like? Warning: Invalid argument supplied for foreach() in /home/utmarka/public_html/dodosquiz/dodosquiz/dodosquiz.php on line 248 I denne linjen står det følgende: foreach ($this_answers[$i] as $col => $data) { Her er hele filen: ? /**************************************************** // Dodo's Quiz Script // Copyrighted by Ying Zhang // http://regretless.com/scripts // No redistribution without authorization // Script released under linkware // that means LINK ME if you use it for your website /****************************************************/ /*********************************************************** // With this script you should able to make multiple quizzes // Just call your quiz with its number. // For example: dodosquiz.php?n=1 will include your quiz_1.php // No changes below this unless you REALLY KNOW what you are // doing. /***********************************************************/ /************************************************************ // Email function added Jan 30, 2003 // Made it compatible with PHP5 April 1, 2008 /************************************************************/ if(!$_GET['n']) exit; require("quiz_".$_GET['n'].".php"); include("header.php"); if($_GET['action'] == "results") { $choices = $_POST['choices']; $total_choices = count($choices); if($total_choices == 0) { echo "<div class=\"rings\">Error</div><div class=\"just\">None of the questions is answered! Please <a href=\"java script:history.back(1)\">go back</a> and answer them!"; } else { if($all_questions_answer && ($total_choices != count($questions_array))) { echo "<div class=\"rings\">Error</div><div class=\"just\">You didn't answer all the questions. Please <a href=\"java script:history.back(1)\">go back</a> and answer them!"; footer(); include("footer.php"); exit; } /********************* MATH QUIZ RESULT **********************/ if($math_quiz) { // calculate the results // declare an array the same size as choices with only 0 $total_results = count($results_array); for($j=1; $j <= $total_results; $j++) { $int_results_array[$j]=0; } for($i=1; $i <= $total_choices; $i++) { $num = trim($choices[$i]); // if the quiz taker has choosen the correct answer if($num == $correct_result) $int_results_array[$correct_result]=$int_results_array[$correct_result]+1; } $max_value = max($int_results_array); // if max_value is the same as the total number of questoins if($max_value == count($questions_array)) { $right = 1; } if($right) $final_result=$results_array[$correct_result]; else { if($math_quiz_show_correct) { $total = count($questions_array); $final_result = $results_array[$math_quiz_show_correct_before]." It seems you have gotten <b>$max_value</b> out of $total correct.".$results_array[$math_quiz_show_correct_after]; } else { $final_result=$results_array[$wrong_result]; } } echo $final_result; email_admin($final_result); footer(); include("footer.php"); exit; } /********************* END OF THE MATH QUIZ **********************/ /********************* TYPE 2 QUIZ RESULT **********************/ if($quiz_2) { // test to make sure the level array is the same size as the result array if(count($level_array) != count($results_array)) { echo "<div class=\"rings\">Error</div><div class=\"just\">The quiz maker didn't provide valid info for this quiz. If you are the quiz maker, please make your level array the same size as your result array in order for the type 2 quiz to work!</div>"; footer(); include("footer.php"); exit; } // calculate the results $total_num_correct = 0; for($i=1; $i <= $total_choices; $i++) { $num = trim($choices[$i]); // if the quiz taker has choosen the correct answer if($num == $correct_result) $total_num_correct++; } // now $total_num_correct should contain how many problems did the quiz taker get right. if($total_num_correct <= $level_array[1]) { $final_result = $results_array[1]; echo $final_result; footer(); email_admin($final_result); include("footer.php"); exit; } $total_levels = count($level_array); for($j=1; $j < ($total_levels-1); $j++) { $k=$j+1; if(($total_num_correct > $level_array[$j]) && ($total_num_correct <= $level_array[$k])) { $final_result = $results_array[$k]; echo $final_result; footer(); email_admin($final_result); include("footer.php"); exit; } } // else the final result must the be the last $final_result = $results_array[count($results_array)]; echo $final_result; footer(); email_admin($final_result); include("footer.php"); exit; } /********************* END OF THE QUIZ II **********************/ // calculate the results // results array //print_r($results_array); // declare an array the same size as choices with only 0 $total_results = count($results_array); for($j=1; $j <= $total_results; $j++) { $int_results_array[$j]=0; } //print_r($choices); for($i=1; $i <= $total_choices; $i++) { $num = trim($choices[$i]); $int_results_array[$num]=$int_results_array[$num]+1; } //print_r($int_results_array); $max_value = max($int_results_array); $total_int_results_array = count($int_results_array); for($i=1; $i<=$total_int_results_array; $i++) { if($int_results_array[$i] == $max_value) { $max_key = $i; break; } } //echo "the max key is $max_key"; //print_r($int_results_array); //echo "max key is $max_key"; $final_result=$results_array[$max_key]; echo $final_result; } // end of else } // end of the result function function email_admin($final_result) { global $admin_email, $email_notify, $HTTP_USER_AGENT, $REMOTE_ADDR, $HTTP_REFERER, $quiz_question; // email admin if it's enabled if($email_notify) { if($final_result != "") { $final_email_result = str_replace("<div class=\"header\">", "", $final_result); $final_email_result = str_replace("<div class=\"just\">", "", $final_email_result); $final_email_result = str_replace("</div>", "\n\n", $final_email_result); $final_email_result = str_replace("<br />", "\n", $final_email_result); // get the quiz taker's info $date = date("Y-m-d H:i:s"); $ip = $_SERVER['REMOTE_ADDR']; $browser_info = $_SERVER['HTTP_USER_AGENT']; $host = gethostbyaddr($ip); $referer = $_SERVER['HTTP_REFERER']; // from info $from_info = " This is the result of the test taker: $final_email_result ------------------------------------------------------------------------------------------ IP: $ip HOST: $host Browser: $browser_info Time: $date Referred by: $referer ------------------------------------------------------------------------------------------"; $subject = "Someone has taken $quiz_question quiz"; //echo "in footer, trying to send mail: $admin_email, $final_result, $from_info, $subject"; mail($admin_email, $subject, $from_info, "From: Test_Taker"); } // end of if final result is not empty } // end of if } function footer() { echo "<div style=\"font-family: Verdana; font-size: 10px;\">Quiz made possible with <a href=\"http://regretless.com/scripts/\" target=\"_blank\">Dodo's Quiz Script</a></div>"; } // end of footer function if(!$_GET['action']) { echo "<div class=\"header\">".$quiz_question."</div>\n<div class=\"just\">".$quiz_description."</div>"; echo "<form action=\"dodosquiz.php?n=".$_GET['n']."&action=results\" method=\"post\">"; foreach ($questions_array as $i => $question) { echo "<div class=\"rings\">". htmlentities($question)."</div>\n"; echo "<div class=\"just\">\n"; foreach ($this_answers[$i] as $col => $data) { if ($col == 'pic') { echo '<img src="'. urlencode($data) . '" />'; } elseif ($col == 'choices') { foreach ($data as $choice => $k) { echo '<label><input type="radio" name="choices[' . $i . ']" value="' . htmlentities($k) . '" \>' . htmlentities($choice) . "</label><br /> \n"; } } } echo "</div><br />\n"; } echo "<input type=\"submit\" value=\"".$submit_button."\" class=\"form\"></form>"; } // end of if not action footer(); email_admin($final_result); include("footer.php"); ?> Lenke til kommentar
OISNOT Skrevet 20. november 2008 Del Skrevet 20. november 2008 Are you the one for Dodo?This is a quiz that finds out your compatibility with Dodo Have fun! What color does dodo like? Warning: Invalid argument supplied for foreach() in /home/utmarka/public_html/dodosquiz/dodosquiz/dodosquiz.php on line 248 What season does dodo like? Warning: Invalid argument supplied for foreach() in /home/utmarka/public_html/dodosquiz/dodosquiz/dodosquiz.php on line 248 What season does dodo like? Warning: Invalid argument supplied for foreach() in /home/utmarka/public_html/dodosquiz/dodosquiz/dodosquiz.php on line 248 Den koden virker ikke med de gamle spørsmål og svarene i eksemplene. Du må bruke det nye formatet. Lenke til kommentar
Anbefalte innlegg
Opprett en konto eller logg inn for å kommentere
Du må være et medlem for å kunne skrive en kommentar
Opprett konto
Det er enkelt å melde seg inn for å starte en ny konto!
Start en kontoLogg inn
Har du allerede en konto? Logg inn her.
Logg inn nå