zohaib87
3/22/2015 - 7:16 AM

Form processor.php

<?php

if ( ($_SERVER['REQUEST_METHOD'] == 'POST') && (!empty( $_POST['naction'] )) ) { 

	// specify your email here
	$to = 'email@domain.com';

	// Assigning data from $_POST array to variables
  if (isset($_POST['nemail'])) { $mail_from = $_POST['nemail']; }
	
	// Construct subject of the email
	$subject = 'News Letter Subscription' . $name;

	// Construct email body
	$body_message .= 'E-mail: ' . $mail_from . "\r\n";

	// Construct headers of the message
	$headers = 'From: ' . $mail_from . "\r\n";
	$headers .= 'Reply-To: ' . $mail_from . "\r\n";

	$mail_sent = mail($to, $subject, $body_message, $headers);

	if ($mail_sent == true){ ?>
		<script language="javascript" type="text/javascript">
		window.alert("Subscribed Successfuly.");
		</script>
	<?php } else { ?>
    <script language="javascript" type="text/javascript">
        window.alert("Error! Please Try Again Later.");
    </script>
	<?php
	} // End else

} // form submitted
        
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" class="form align-center">
    <div class="row">
      <div class="col-md-6 col-md-offset-3">
                                
        <div class="newsletter-label font-alt">
          VOLETE RICEVERE LA NOSTRA NEWSLETTER
        </div>
                                
        <div class="mb-20">
          <input placeholder="INDIRIZZO EMAIL" class="newsletter-field input-md round mb-xs-10" type="email" name="nemail" pattern=".{5,100}" required/>
                                    
          <button type="submit" class="btn btn-mod btn-medium btn-round mb-xs-10" name="naction" value="submit">
            SOTTOSCRIVO
          </button>
        </div>
                                
        <div class="form-tip"> 
          — Credeteci, non inviamo spam —
        </div>
                                
      </div>
    </div>
</form>