İnternet Programlama Dersi – 1 (Güz-2017) Hafta-8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
<html> <head> <title>Anket Programı</title> <meta charset="UTF-8"> </head> <body> <?php if (count($_POST) > 0) { $dosyax= fopen("yaz.txt","a"); if($dosyax) { foreach ($_POST as $indis => $deger) { $yazilacak=$indis.";".$deger."\n"; fwrite($dosyax,$yazilacak); } fwrite($dosyax,"----\n"); fclose($dosyax); echo "Bilgileriniz Kaydedildi!<br>"; } else echo "Bilgiler Kaydedilemedi!"; } ?> <form method="post"> <table border="1" width="100%"> <?php $dosya = fopen("dosya.txt", "r"); if ($dosya) { $veriler = fread($dosya, filesize("dosya.txt")); $satirlar = explode("\n", $veriler); $sayac = 0; foreach ($satirlar as $satir) { $bilgiler = explode(";", $satir); if (count($bilgiler) > 1) { $soru = $bilgiler[0]; $sayac++; echo "<tr>"; echo "<td>Soru-" . $sayac . ") " . $soru . "</td>"; echo "</tr>"; echo "<tr><td>"; for ($i = 1; $i < count($bilgiler); $i++) { $cevap = $bilgiler[$i]; $yaz = ""; if ($i == 1) $yaz = "checked"; if (strlen($cevap) > 0) { ?> <input type="radio" name="soru-<?php echo $sayac; ?>" value="<?php echo $cevap; ?>" <?php echo $yaz; ?> > <?php echo $cevap; ?> <?php } } echo "</td></tr>"; } } fclose($dosya); } else{ echo "<tr><td style='color: red; text-align: center;'>"; echo "Dosya Okunamadı!"; echo "</td></tr>"; } ?> <tr> <td > <input type="checkbox" required> Gönderimi Kabul Ediyorum! </td> </tr> <tr> <td style="text-align: center;"> <input type="submit" value="Gönder"> </td> </tr> </table> </form> </body> </html> |
Soru Dosyası
Okumaya devam et
Son Yorumlar