paste.php.lv / koda glabātuve (vēl mums ir forumi un irc kanāls)

Autors: Mad182

Komentārs: form

Skatīt bez rindiņu numerācijas

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=utf-8">
  5. <meta name="generator" content="PSPad editor, www.pspad.com">
  6. <title>Subscribe</title>
  7.  
  8. <style type="text/css">
  9. body {
  10. background: #444;
  11. font: 11px verdana;
  12. color: #fff;
  13. }
  14. #subscribe-box {
  15. margin: 50px auto;
  16. background: #333;
  17. border: 1px solid #000;
  18. width: 300px;
  19. padding: 10px;
  20. }
  21. .done {
  22. color: #0f0;
  23. }
  24. .error {
  25. color: #f00;
  26. }
  27. </style>
  28.  
  29. </head>
  30. <body>
  31.  
  32.  
  33. <div id="subscribe-box">
  34. <?php
  35. $filename = 'yourfile.txt'; //where to store data
  36.  
  37. if(isset($_POST['mail'])) {
  38. $newcontent = htmlspecialchars(trim($_POST['mail']));
  39. if(!empty($newcontent)) {
  40. if (is_writable($filename)) {
  41.  
  42. if (!$handle = fopen($filename, 'a')) {
  43. echo '<p class="error">Cannot open file (' . $filename . ')</p>';
  44. exit;
  45. }
  46.  
  47. if (fwrite($handle, $newcontent."\n") === FALSE) {
  48. echo '<p class="error">Cannot write to file (' . $filename . ')</p>';
  49. exit;
  50. }
  51.  
  52. echo '<p class="done">Thanks! You will be informed.</p>'; //success
  53. fclose($handle);
  54. } else {
  55. echo '<p class="error">Sorry, the file &quot;' . $filename . '&quot; is not writable</p>';
  56. }
  57. }
  58. }
  59. ?>
  60. <form action="" method="post">
  61. <p>Please enter email address to be informed of websites Grand Opening!</p>
  62. <input type="text" name="mail" />
  63. <input type="submit" value="Subscribe" />
  64. </form>
  65.  
  66. </div>
  67.  
  68. </body>
  69. </html>

© 2003 – 2010 PHP.lv komanda. Visas tiesības ir paturētas. Izņemot saturu, kurš ir tā autora īpašums, ja nekas nenosaka savādāk.