php Subscribe Form
How to create a simple Subscribe Mail Form for MailList Controller with php
This article gives Information about how to create a simple subscribe web form with php. Such a script is often called mail form or form mailer.
MailList Controller contains a built-in "HTML Web Form Generator", which will build the HTML web form and the required php script for you. There is no manual coding required. The generator is an easy to use tool to integrate a html subscribe/remove form into an existing web page. The tool will add the form code to the web page and will also create the required php script. The web form is based on HTML and PHP, which is widely spread and available on most web servers.
How to Create a simple Subscribe Mail Form for MailList Controller with php
Custom HTML/PHP Sample Code:
If you have PHP installed on your web server, then you can use the following code for a simple php subscribe (mail) form. You can use the same code for remove, just change the subject to the remove-keyword ("Remove" by default).
Add the following code to your HTML page:
<form method="POST" action="enter the URL
to your PHP page here">
<p>Name: <input type="text" name="Name" size="20"></p>
<p>Email: <input type="text" name="Email" size="20"></p>
<p><input type="submit" value="Submit" name="Submit"></p>
Create a new php file (e.g. subscribe.php) with any texteditor (e.g. notepad)
and place it on your web server.
Please update the URL in the HTML form. (e.g. subscribe.php)
## CONFIG ##
# LIST EMAIL ADDRESS
$recipient = "enter the lists email address here";
# SUBJECT (Subscribe/Remove)
$subject = "Subscribe";
# RESULT PAGE
$location = "enter the URL of the result page here";
## FORM VALUES ##
# SENDER - WE ALSO USE THE RECIPIENT AS SENDER
# DON'T INCLUDE UNFILTERED USER INPUT IN THE MAIL HEADER!
# SEE ALSO: How to protect a php Email Form using php mail or mb_send_mail against Mail Header Injection
$sender = $recipient;
# MAIL BODY
$body .= "Name: ".$_REQUEST['Name']." \n";
$body .= "Email: ".$_REQUEST['Email']." \n";
# add more fields here if required
## SEND MESSGAE ##
mail( $recipient, $subject, $body, "From: $sender" ) or die ("Mail could not be sent.");
## SHOW RESULT PAGE ##
header( "Location: $location" );
Now save both files to your web server and click on "Submit".
The php script will not work on your local computer - please upload it to your web server.