Location: PHPKode > scripts > CSS3 Email Subscription > email-subscription-css/index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">

<head>
<!-- Poppup script -->
<script type='text/javascript' charset='utf-8' src='jquery.js'></script>
  <script type='text/javascript' charset='utf-8' src='popbox.js'></script>
    <script type='text/javascript' charset='utf-8'>
    $(document).ready(function(){
      $('.popbox').popbox();
    });
  </script>
<!-- Poppup End -->

    
<link href="style.css" type="text/css" rel="stylesheet">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Subscription</title>

<!-- Email Validation using JavaScript: starts -->
	<script type="text/javascript">
        function validateForm()
            {
            var x=document.getElementById('textbox').value;
             var atpos=x.indexOf("@");
            var dotpos=x.lastIndexOf(".");
            if (x==null || x=="")
              {
              alert("Please fill the email");
              return false;
              }
           
            else if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
              {
              alert("Not a valid e-mail address");
              return false;
              }
              else{
                  alert("successfully subscribed");
              }
           }
        
    </script>
    <!-- Email Validation using JavaScript: end -->

</head>

<body>
<div class='popbox'>
   <a class='open round' href='#'>Subscribe Me!</a>
 <!-- subscribtion pop pup box starts -->     
    <div class='box'>
     <form name="form" method="post" onsubmit="return validateForm();">
		<div id="outerbox">
     		<div id="inner1">
        		<div id="text1">Subscribe for your NewsLetter</div>
           		<div id="mailbox"></div>
            <input name="email" type="text" id="textbox" size="30" onclick="this.style.backgroundColor='#f0f0f0'" onblur="this.style.backgroundColor='#ffffff'" value=""/>
    		</div>
     
    		<div id="inner2"></div>
    
    		<div id="inner4"></div>
    
   			<div id="inner3">
        		<div id="text2">I want to receive in my Email</div>
             	<input type="submit" value="Submit" id="submitbutton">
            
    		</div>
		</div>
	</form>

<!-- subscribtion pop pup box ends -->
</div>
</div>
<!-- PHP script to store email in text document -->
<?php
   
    if(isset($_POST['email'])) {
        $a =$_POST['email']."\n";
        $myFile = "subscriber.txt"; //Change the file name you want.
        $fh = fopen($myFile, 'a') or die("can't open file");
        fwrite($fh, $a);
        fclose($fh);
        header("location:./index.php");
    }
?>
<!-- PHP Script end -->
</body>
</html>
Return current item: CSS3 Email Subscription