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
Marketing Articles | MLM Marketing With Email Autoresponders ...
If you are really serious about growing your network marketing business you cannot ignore the power of email autoresponders. Just click on my link below and I will give you my top autoresponder recommendation. It is inexpensive and very ...

Autoresponders with PHP
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 ...

Ritual Image Design » 10 Advanced PHP Tips To Improve Your Programming
10 Advanced PHP Tips To Improve Your Programming. « Missing Beatles Track Confirmed · Life magazine photo collection goes online ». Post a Comment. You must be logged in to post a comment. Navigation ...

Autoresponder-like Script | FreeLance Home Jobs
The requirement is to upgrade an autoresponder php script in order to have the functionality of an online autoresponder service with the ability of giving people sequential autoresponder accounts with username and password. ...

Php follow up autoresponder - both basic and pro versions ...
cheap autoresponder,affordable autoresponder,php autoresponder,email marketing script,basic pro autoresponder. Our php/mysql scripts - follow up autoresponder, password protection script, click tracking script and free article ...

How can I set up an autoresponder on my blog?
Home | Programming and PHP | How can I set up an autoresponder on my blog? How can I set up an autoresponder on my blog? Question asked by uzomaeze on November 12th, 2008. No Gravatar. my question has been searched every where possible ...

php validation help - PHP
php validation help - PHP Community and Forum - Our PHP forum is the place for Q&A-style discussions related to this popular development language. LAMP programmers will appreciate our separate Apache forum, within the Networking ...

Live Help - Live Chat Customer Service Software, PHP Live Help ...
Our PHP Live Help Server Software is a complete customer support solution for Windows and Unix-based web servers. Our Live Help software utilizes PHP and MySQL technology and is installed on your own web server - no monthly or ...

Free Polyphonic Ringtones,Mobile Softwares,Indian Songs,Pakistani ...
Award Space, 200 MB, No ads, FTP, Browser, CGI, PHP, SSI, Front Page Server Extensions, Perl, Domain or Subdomain, Bandwidth limit 5 GB/month. MySQL database. POP3, Web-based Email. Autoresponders. Addon domains. File size limit 500 KB. ...

Freelance Project | Fix Autoresponder Problem
Fix Autoresponder Problem 24.10.08. Posted in MySQL, PHP. I need a programmer that can do this job in 1 day or less. Please do not bid if you can not do the work in 1 day or less. I have an autoresponder script and I have had some ...

 


 

© 2007 articlesreader.com - All Rights Reserved