Hi,
I’m on wordpress using the above plugin. The plugin requires PHP code to have no PHP start and end tags for it to work. I am successfully using shortcode, however part of the code – which works on a normal PHP page, is not working here and I can’t work out why as I’m a bit of a newbie.
The test page is http://www.learnhowtostudy.net/php/
The results page is here : http://www.learnhowtostudy.net/phpanswer/
The code gives the right result if the answer is correct, but does not if it’s wrong. The code I’m using is (the following is for one of the inputs):
[php]if ($_POST[‘answer1’] == “formats”) { $ans = $ans + 1; print ("");} else { print ("");print “(your answer was $answer1)”;}
[/php]
SO, the right answer is formats and this gets a tick on the page. IF you put in something else, the answer should show a cross plus what you wrote. However it just shows a cross along with the words ‘your answer was’.
I’ve tried a number of things but can’t get it to work. Can anyone suggest a fix? Thanks!
FYI, this is the full code (in this plugin, HTML has a ?> before and a <? after the HTML) and NO PHP code before or after the PHP :
[php] $ans = 0;
?>
Check below to see which ones you got wrong.
There are a number of different formats <?
if ($_POST[‘answer1’] == “formats”) { $ans = $ans + 1; print ("");} else { print ("");print “(your answer was $answer1)”;}
?> or methods for organising study notes and it can come down to personal <?
if ($_POST[‘answer2’] == “personal”) { $ans = $ans + 1; print ("");} else { print ("");print “(your answer was $answer2)”;}
?> preference. One of the best ways is to write your study notes on loose <?
if ($_POST[‘answer3’] == “loose”) { $ans = $ans + 1; print ("");} else { print ("");print “(your answer was $answer3)”;}
?> leaf paper and file these into a separate display folder <?
if ($_POST[‘answer4’] == “folder”) { $ans = $ans + 1; print ("");} else { print ("");print “(your answer was $answer4)”;}
?>for each subject. This allows you to add in good handouts <?
if ($_POST[‘answer5’] == “handouts”) { $ans = $ans + 1; print ("");} else { print ("");print “(your answer was $answer5)”;}
?> you have been given and keep improving and adding <?
if ($_POST[‘answer6’] == “adding”) { $ans = $ans + 1; print ("");} else { print ("");print “(your answer was $answer6)”;}
?> to your study notes.
<?echo "
Your score for this quiz is $ans out of 6.
"; [/php]