SHARE
TWEET

Untitled

a guest Aug 19th, 2019 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <form method="POST" id="quis">
  2.   <h3>「にゃん」という鳴き声の可愛い生き物は?ひらがな2文字で回答して下さい。</h3>
  3.   <p>回答:<input type="text" name="q1" size="20" value="<?php echo $_POST['q1'] ?>"></p>
  4.   <?php
  5.       if ($_POST['q1'] === "ねこ") {
  6.           echo "<p class='ok'>〇</p>";
  7.       } elseif (strlen($_POST['q1']) > 2) {
  8.           echo "<p class='error'>文字数がオーバーしています</p>";
  9.       } elseif (!empty($_POST['q1'])) {
  10.           echo "<p class='error'>×</p>";
  11.       }
  12.   ?>
  13.   <h3>次のうち、魚はどれですか?(回答は複数あるかもしれません)</h3>
  14.   <p>
  15.     <input type="checkbox" name="q2[]" value="1" <?php if($_POST['q2'][0] === "1"){echo "checked";} ?>>まぐろ
  16.     <input type="checkbox" name="q2[]" value="2" <?php if($_POST['q2'][1] === "2"){echo "checked";} ?>>いわし
  17.     <input type="checkbox" name="q2[]" value="3" <?php if($_POST['q2'][2] === "3"){echo "checked";} ?>>ほうれん草
  18.   </p>
  19.   <?php
  20.       if ($_POST['q2'][0] === "1" && $_POST['q2'][1] === "2" && $_POST['q2'][3] === NULL) {
  21.           echo "<p class='ok'>〇</p>";
  22.       } elseif (!empty($_POST['q2'])) {
  23.           echo "<p class='error'>×</p>";
  24.       }
  25.   ?>
  26.  
  27.   <h3>どちらが猫ですか</h3>
  28.   <p>
  29.     <input type="radio" name="q3" value="1" <?php if($_POST['q3'] === "1"){echo "checked";} ?>>マンチカン
  30.     <input type="radio" name="q3" value="2" <?php if($_POST['q3'] === "2"){echo "checked";} ?>>ネザーランドドワーフ
  31.   </p>
  32.   <?php
  33.       if ($_POST['q3'] === "1") {
  34.           echo "<p class='ok'>〇</p>";
  35.       } elseif (!empty($_POST['q3'])) {
  36.           echo "<p class='error'>×</p>";
  37.       }
  38.   ?>
  39.   <p>
  40.     <input type="submit" value="送信">
  41.   </p>
  42. </form>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top