ArticlesReader.com Menu
Newest Articles
Most Viewed Articles
ArticlesReader.com RSS
Submit Article
Login
Signup
Search the articles

Articles Main Categories
Advice
Animals
Automobiles
Business
Career
Communications
Computer Programming
Computers
Entertainment
Environment
Family
Fashion
Finance
Food
Health & Medical
Home & Garden
Humor
Internet Business
Internet Marketing
Legal
Leisure & Recreation
Marketing
Other
Politics
Reference & Education
Religion
Self Improvement
Sports
Technology & Science
Travel
Writing
Subscribe
Receive alert message from us when new articles submitted to our site for free.

Enter your name

Enter your email

Syndicate

















Related Products
Home::CGI

Autoresponders With PHP

Author : Robert Plank

First off, check out the URL below. You'll learn how to make
that today. http://www.jumpx.com utorials/3/signup.html

Fill out your e-mail address on the page you see. (I promise
it's not being saved anywhere.) Then, wait a minute or two and
check your mail. You should get a message from Gumby
(null@jumpx.com) containing a sample autoresponder message.

Today, we're going to learn three easy things: redirection, mail
sending, and form submission.

When we finish with that, you will know how to put those
components together and create an autoresponder. Because if you
think about it, that's all an autoresponder does. Somebody
enters in their e-mail address, are sent an e-mail message, and
then are redirected to a new page.

Of course there are more complex autoresponders, like Gary
Ambrose's Opt-In Lightning, or Wes Baylock's Mail Master Pro
which handle multiple follow-ups and record the e-mail addresses
of those who have signed up for the responder. But today we're
just going to focus on how to make a very basic, very simple
autoresponder.

Hopefully, you've seen what form objects in HTML look like.
Here's some code you can use for an example:

Enter Your E-Mail
Address:



Copy and paste this code into a file called "signup.html" and
upload it to your web server. You'll see a text box waiting for
your visitor to enter his or her e-mail address so they can be
sent that autoresponse message.

Of course, the form won't work just yet because, if you look at
the first line of that HTML code I gave you, you'll see that the
form submits to a script called "some-script.php". And we
haven't made that just yet.

Look on the second line of "signup.html", at the last half of
the line. You should be familiar with HTML tags, but if you're
not, an HTML tag consists of two parts: the parent tag and the
attributes.

The parent tag is simply the tag's designation. For example, if
you had a slice of HTML code that looked like this:



Then the parent tag would be "font". The rest of what's enclosed
in the tag tells the browser what to do with it. For example, in
this tag the attributes are that the font should be Verdana with
size 1.

Why am I telling you all this? Because it relates to the HTML
code you see in signup.html.

Now, when you look at this: size="30">

The code tells the receiving browser that this is an "input"
tag, meaning that it's a form field. The name of this item is
"email" and its size is 30, meaning this text box should be 30
characters in width.

When the form is submitted, it takes all the values of all the
fields inside that form and throws it at its destination. In
this case, our destination is "some-script.php".

If you're lost, this will all make a whole lot more sense once
you try this next step.

Make a file called "some-script.php" and paste this line of code
into it:



Upload the script in the same folder as signup.html, and go to
"signup.html". Type your e-mail address in and click the submit
button.

You should see a new page containing just your e-mail address
and nothing else.

Is this starting to make sense? You told the PHP script to dump
the contents of the variable called "email" to the screen, and
you just submitted a form with a text box called "email".

If you want to try one more exercise like this, change the name
of the text box to, say, "goober" in signup.html and change the
$email in some-script.php to $goober. Upload both, go to
signup.html, and type anything into the text box. You'll get the
same result.

This is how you'll pass data from forms (like text fields, drop
down menus, radio buttons and the like) along into the PHP
scripts you create.

We've just covered how to submit form elements into PHP. Now
let's focus on sending mail.

PHP has a really simple function that uses whatever mail sending
program is installed on your server to send messages to the
outside world. If you have a crappy web server, this step might
not work and you'll have to use a different web host if you want
to try this.

But if you're on a good web host that has PHP installed
*correctly*, this shouldn't be a problem.

Up until now we haven't used functions in PHP too much, aside
from simple things like include() and header(). Today's your
lucky day, because functions work in a very similar way to HTML
tags. You have the parent tag, and the attributes (or
parameters).

The mail() function basically works like this:

mail("recipient","subject","body","headers");

Let's start off by sending a simple e-mail message to yourself.
We won't need any special headers this time around, so this will
be quick and painless. Copy this one line of code into
"mailtest.php":

billg@microsoft.com","Hello","Hi. This is the body
of my message."); ?>

Replace "billg@microsoft.com" with your actual e-mail address,
but be *sure* to keep quotes around it. Save it, and upload
mailtest.php to your web server and run it in the browser. You
should see a blank page. Wait a few minutes and check your mail.
You should see a mysterious mail message in your box with the
subject "Hello" and the message "Hi. This is the body of my
message."

If you're using a free e-mail service or a weird ISP, the
message won't come through because a lot of mail servers these
days require that certain headers are present in the message.

Let's do that now.

What's below isn't important enough to explain thoroughly, but
it's just header information that is interpreted by the mail
server. This data tells us that we're sending a plain text
e-mail, that the message came from your e-mail address (and
gives your name), and tells us that the e-mail "client" we used
was PHP.

$headers = "Content-Type: text/plain; charset=us-ascii From:
$myname <$mymail> Reply-To: <$mymail> Return-Path: <$mymail>
X-Mailer: PHP";

This is the code you should have by this point, complete with
the header information and the variables which tell the script
what your name and e-mail address are:


$email = "billg@microsoft.com";

$myname = "Your Name Here"; $mymail = "your@email.here";

$headers = "Content-Type: text/plain; charset=us-ascii From:
$myname <$mymail> Reply-To: <$mymail> Return-Path: <$mymail>
X-Mailer: PHP";

mail($email,"Hello","Hi. This is the body of my
message.",$headers);

?>

Notice how we've simplified things a bit by using variables in
the mail() function. That way we don't have to retype things.
This method also looks better (in my opinion anyway) and is
easier to tweak once you're ready to actually customize it for
yourself.

Try this out again. Believe it or not, but you just made your
first autoresponder! Before we move on let's make this look even
cleaner:


$myname = "Your Name Here"; $mymail = "your@email.here";

$subject = "Hello"; $body = "Hi. This is the body of my message.
Notice how I can continue typing right on the next line!";

$headers = "Content-Type: text/plain; charset=us-ascii From:
$myname <$mymail> Reply-To: <$mymail> Return-Path: <$mymail>
X-Mailer: PHP";

if ($email != "") { mail($email,$subject,$body,$headers); }

?>

All I did here was just make things look nicer, but notice how I
removed the line that set $email to "billg@microsoft.com." This
is because the value of $email will be passed to the script from
that form we made earlier.

This also sends the e-mail message ONLY if the value of $email
is not blank. So if someone just hit the submit button without
entering an address, the script won't try to send the e-mail
message.

Everything should be ready for you to try out now. Re-upload
"some-script.php" and go to signup.html. Enter your e-mail
address in the field, hit submit and wait for that mail message
to arrive.

There's only one step left to making this autoresponder
complete. And that's sending the user somewhere so they aren't
given a blank page.

Find this line in your script: if ($email != "") {
mail($email,$subject,$body,$headers); }

And paste this directly underneath it:
header("Location:http://www.jumpx.com"); die();

Try the autoresponder out. You'll see that once the autoresponse
message is sent, you're directed to www.jumpx.com. Now, go ahead
and change it to whatever URL you want to use. Or, make use it
with a variable so the end result is like this:


$myredirect = "http://www.my-domain-name.com hankyou.html";

$myname = "Your Name Here"; $mymail = "your@email.here";

$subject = "Hello"; $body = "Hi. This is the body of my message.
Notice how I can continue typing right on the next line!";

$headers = "Content-Type: text/plain; charset=us-ascii From:
$myname <$mymail> Reply-To: <$mymail> Return-Path: <$mymail>
X-Mailer: PHP";

if ($email != "") { mail($email,$subject,$body,$headers); }
header("Location:$myredirect"); die();

?>

Don't forget to change the values above.
"http://www.my-domain-name.com hankyou.html" needs to point to
the URL where thankyou.html is stored.

You're done. Don't forget to send John feedback for me. If
you're really curious as to how to do something in PHP, I might
just write an article on it.

Spam emails More free articles

Related articles


  1. 5 CGI Scripts You Must Use to Turn Your Site Into a Powerhouse
  2. Clever Profit Growth Software
  3. Why Aren't You Using CGI
  4. Use CGI to Automate Your Web Site
  5. CGI: What the Heck Is That?
  6. CGI Security Issues
  7. How to Stop Digital Thieves with CGI
  8. Quick Intro to PHP Development
  9. Better Writing: What Works and What Doesn't
  10. Password Protection and File Inclusion With PHP
  11. Autoresponders With PHP
  12. Track your visitors, using PHP
  13. PHP On-The-Fly!
  14. PHP and Cookies; a good mix!
  15. Screen scraping your way into RSS
  16. Mastering Regular Expressions in PHP
  17. ASP, CGI and PHP Scripts and Record-Locking: What Every Webmaster Needs To Know
  18. Open Source Scripts
  19. this is a test
  20. An Extensive Examination of the PHP:DataGrid Component: Part 1
  21. PHP:Form Series, Part 1: Validators & Client-side Validation
  22. Design an Online Chat Room with PHP and MySQL
More related feeds
Autoresponders with PHP
Because if you think about it, that's all an autoresponder does. Somebody enters in their e-mail address, are sent an e-mail message, and then are redirected to a new page. Category:PHP Basics Tutorials Author: PHPreg.com ...

ReadyWire - cPanel FREE UPGRADE OFFER / End User Support / SSL ...
Unlimited domains, parked domains, subdomains, mail accounts, mail forwarders, autoresponders, FTP accounts, and much more. Overselling is enabled. * Fantastico De Lux & RVSkin/RV Admin * Free RVSkins & Fantastico ...

How to best use your autoresponder for your email marketing campaigns.
What is an autoresponder? An email autoresponder allows you to follow up your potential customers at a predefined timeframe automatically through emails. You may acquire this functionality by installing a script on your webhosting or ...

:::: 1+1=1 :::: for full featured cPanel Shared hosting accounts!
50 Auto responders WebMail: RoundCube; SquirrelMail and Horde 50 FTP Accounts PHP version 5.2.x Zend Optimizer and cURL PERL / CGI Customized Error Pages (eg 404) Password Protect Directories Cron Jobs Server Side Includes (SSI) ...

Yet Another Article About E-mail Courses?
A couple of short video tutorials that should get you started: http://www.xtreeme.com/followupxpert/walkthrough.php?a=ArticleEC. Of course, the autoresponder tool is pretty advanced. For example, you can set it up to work with a sign-up ...

Autoresponders
How does one do a pre-built message that can be sent out to returning leads?

GeekStorage 50% Off & 50% More! LiteSpeed, Ruby, PHP5, Hourly Backups!
1 GB CDP & RAID Protected Storage Space * 20 GB Premium Bandwidth * LiteSpeed, Apache 2.2 & PHP 5 * No Additional Domains * 5 Email Accounts * 5 Email Forwarders * 5 Email Auto-responders * 2 MySQL Databases * 2 PostgreSQL Databases ...

Do You Know Why Autoresponders Are So Important?
Autoresponders are one of the most effective ways to minimize the amount of time you spend building your Internet business. Here are a few ways autoresponders are important and how you can maximize your efforts using them.

Part I: Email Marketing Training Series
Email auto responders have been gaining in popularity as a direct marketing technique and as a drip marketing technique. This technique uses the power of emails to send to your entire lead base or to those visitors that you choose. ...

How Autoresponders Have Revolutionized Email Marketing
Online marketers are relying more and more on autoresponders maximize sale and to take care of all their email marketing needs.

 


 

© 2007 articlesreader.com - All Rights Reserved