rendered paste body<?php ob_start(); ?><html><head><style type='text/css'> form input { border:1px solid #c00; margin:4px 0;}</style></head><body><?phpif(!isset($_POST['submit'])) {?> <form method='post' action="<?php echo $_SERVER['PHP_SELF']; ?>"> enter email:<br /> <input type='text' name='email' maxlength='30' size='30' /><br /> <input type='submit' name='submit' value='Post' /> </form><?php} else { if(!empty($_POST['email'])) { $pattern = "/^[A-z0-9\._-]+" . "@" . "[a-z0-9][a-z0-9-]*" . "(\.[a-z0-9_-]+)*" . "\.([a-z]{2,6})$/i"; if(preg_match($pattern,$_POST['email'])) { $email = $_POST['email']; $filename = 'usermail.txt'; if(is_readable($filename)) { $fp = fopen($filename, 'r'); $fsize = filesize($filename); if($fsize > 0) { while(!feof($fp)) { $str = fgets($fp,$fsize); //echo $str; if(strcasecmp($str,$email) == 1) { $match = 1; break; } else { $match = 0; } } } if($match == 0) { $fp = fopen($filename, 'a'); if(fwrite($fp, $email . "\n")) { echo 'Thank you for your submission.<br />'; } else { echo 'Input error.'; } } else { echo 'mail address exists.'; } fclose($fp); } else { $filename = 'usermail.txt'; $fp = fopen($filename, 'w'); echo 'Preparing Output file...'; header('Refresh:3; URL=filefunc.php'); } } } else { echo 'field cannot be empty'; }}ob_end_flush();?> </body></html>