Results 1 to 3 of 3

Thread: php adjustment to send a confirmation email

  1. #1
    Join Date
    Jul 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default php adjustment to send a confirmation email

    Hello,

    I have looked through the forum but can't quite find what I am looking for. I have a form on the website which is in html code. I like the layout of the form so don't really want to change it. The action of the form is "tellus.php3"

    Currently they are redirected to a page that says thank you, with a link back to the home page, but what I would also like is a confirmation email sent to them and then I would change the message to 'you will receive an email shortly'. It is purely to sign up for emails so it does not contain password details etc.

    I do use a free newsletter subscription service where you can currently use their subscription form and then they have to confirm within five days via an email, but it only asks for an email and we need to collect name and phone numbers for the business as well and it doesn't have that option.

    My current tellus.php file is:

    Code:
    <?
    
    PRINT "<center><FONT SIZE=3 face=arial rounded MT bold>"; PRINT "Thank you for submitting your information.\n";
    PRINT "You will now begin receiving property information.\n<br>Please <a href=/index.php> click here </a>to return to the home page.  Thank you.";
    
    PRINT "</FONT></center>";
    
    
    mail("subscribe@xxxx.com", "Information from form submitted", "First name: $firstname\nLast name: $lastname\nEmail address: $emailaddress\nPhone number: $phonenumber\nExtension: $dextension\nInfo: $otherinformation");
    ?>
    If anyone can see if I can just add something to this to have a confirmation email sent I would really appreciate it as I do not know PHP at all.

    Thank you.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    The first three lines output text to the screen (html).
    The fourth uses mail() to send an email, and this is to your default email to collect the info.
    Add the following line below that:
    @mail($emailaddress,'Newsletter Confirmation','You signed up and will receive an email soon.');

    That will work, but there are a number of potential problems with this script. Since you are asking to keep this simple, this may be all you need.

    But here are some things to keep in mind:
    -You said "php3"-- is this really a php version 3 script? I'd advise moving to at least 4 if not 5 or even 6 (which will be standard soon). PHP4 is very capable, but PHP3 is missing some major components so you won't even really be able to ask for help here since we all only know how to use PHP including the newer commands. (It's possible to look up which ones don't work in PHP3, but that will leave us with some things that can't be done without rewriting it ourselves.)
    -You're using "short tags" in this script. <?php and ?> are standard. <? and ?> are lazy and don't work on some servers. This may not seem significant, but if the page doesn't work at all, that may be the problem.
    -I used "@" in front of mail() to suppress errors. If the email is not formatted correctly, it will give an error, so what I did will just stop that from displaying. But that won't handle some alternative (like saying "your email isn't valid, please try again"), so they just won't get an email. When you receive a subscription notice, just check if the email is valid. In the few cases it isn't, hopefully the users will figure out that it didn't work.
    -My addition assumes mail() is already working on your server. If the whole script works and you get an email confirmation, then this will be fine. If not, and it doesn't work now, mail() may not be supported because you don't have a mailserver setup.
    -This will not generate a pretty email. In most cases this is fine because the email is going to you, rather than to the customer. It's possible to make the customer's email fancier and add a "reply-to" and "from" address, even make it html, but that's more complex, and at that point you'd probably want to verify the data as well.


    Hope this helps, and remember that this code is very basic. It should work for your current purposes though.


    By the way, the use of "<center>" is not standard-- you should switch it for a <div> with CSS to center it. It probably won't hurt too much to use that, but if you start having layout problems, that may be one of the causes.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jul 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you

    I will try adding that line. As I mentioned I do not know how to use php at all. I did this last year and then ended up not using it due to using the newsletter program, but as mentioned we need to receive more info. If I try this form, an email is sent to us with the info but it doesn't check the format and it does not send an email to the person to confirm and as this is my boyfriend's website, he really wants them to get the email.

    If there was a free newsletter program that gave a form where greater info could be captured that would be easier, or if the subscribe/unsubscribe form could be altered to allow more info that could then be emailed to us then that would be even better, but right now, and as I am away and don't have all the extra files with me, this will have to do right now.

    I appreciate the help.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •