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

Autors: Mad182

Komentārs: form

Skatīt ar rindiņu numerāciju

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta name="generator" content="PSPad editor, www.pspad.com">
  <title>Subscribe</title>
 
  <style type="text/css">
    body {
      background: #444;
      font: 11px verdana;
      color: #fff;
    }
    #subscribe-box {
      margin: 50px auto;
      background: #333;
      border: 1px solid #000;
      width: 300px;
      padding: 10px;
    }
    .done {
      color: #0f0;
    }
    .error {
      color: #f00;
    }
  </style>
 
  </head>
  <body>
 
 
    <div id="subscribe-box">
<?php
$filename = 'yourfile.txt'; //where to store data
 
if(isset($_POST['mail'])) {
  $newcontent = htmlspecialchars(trim($_POST['mail']));
    if(!empty($newcontent)) {
    if (is_writable($filename)) {
 
    if (!$handle = fopen($filename, 'a')) {
      echo '<p class="error">Cannot open file (' . $filename . ')</p>';
      exit;
    }
 
    if (fwrite($handle, $newcontent."\n") === FALSE) {
      echo '<p class="error">Cannot write to file (' . $filename . ')</p>';
      exit;
    }
 
      echo '<p class="done">Thanks! You will be informed.</p>'; //success
      fclose($handle);
    } else {
      echo '<p class="error">Sorry, the file &quot;' . $filename . '&quot; is not writable</p>';
    }
  }
}
?>
      <form action="" method="post">
      <p>Please enter email address to be informed of websites Grand Opening!</p>
      <input type="text" name="mail" />
      <input type="submit" value="Subscribe" />
      </form> 
 
    </div>
 
  </body>
</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.