function generateForm($form, $inputs) { $csrf = csrfCode(); $a = ''; foreach ($form as $name => $value) { $a .= ' ' . $name . '="' . $value . '" '; } $form = "<form {$a}><input type='hidden' name='ver' value='{$csrf}'/><table>"; foreach ($inputs as $input) { if ($input == '') { $form .= '<tr><td colspan="2"> </td></tr>'; } elseif (is_string($input)) { $form .= '<tr><td colspan="2">' . $input . '</td></tr>'; } else { $elem = '<input '; foreach ($input as $name => $value) { if ($name != 'prompt') { $elem .= " {$name}=\"{$value}\" "; } } $elem .= ' />'; if (array_key_exists('prompt', $input)) { $form .= "<tr><td>{$input['prompt']}<td>{$elem}</td></tr>"; } else { $form .= "<tr><td colspan='2'>{$elem}</td></tr>"; } } } $form .= '</table></form>'; return $form; }
</script> <style> .question{ transition:background-color 0.5s; -webkit-transition:background-color 0.5s; -moz-transition:background-color 0.5s; -o-transition:background-color 0.5s; -ms-transition:background-color 0.5s; background-color:white; } </style> <div class='alert_neut'><b>Hotkeys:</b> space to display next hidden answer, backspace to hide last revealed answer, enter for fetching more questions</div> <br> <form action="randq.php" method="POST" id="nextq"> <input type="hidden" name='ver' value="<?php echo csrfCode(); ?> "/><?php //can just copy code to submit any invalid request ?> <div id='options'> <?php echo $checkboxoptions; ?> </div> <div id='questions'> <?php //QID,isB,Subject,isSA,Question,MCW,MCX,MCY,MCZ,Answer //--todo-- 'Google This' functionality echo $q->allToHTML(<<<HEREDOC <div class='question'>