SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    VICTORY IS MINE! luchazard's Avatar
    Join Date
    May 2001
    Location
    USA
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can someone find the bug in this script??

    Here it is:
    PHP Code:
    <?

    // check for first & last name

    if ($first_name==""||$last_name=="") {

    echo(
    "You need to provide your first & last name!");

    }

    // check for sender's email

    if ($from_email=="") {

    echo(
    "You need to provide your email address!");

    }

    // check for at least one recipiant email

    if ($to_email=="") {

    echo(
    "You need to provide at least one recipiant email address!");

    }

    // validate sender's email

    if (!eregi("^[-a-z0-9\._]+@[-a-z0-9\._]+\.+[a-z]{2,3}$"$from_email)) {

    echo(
    "You provided a improper email address!");

    }

    // validate recipiant email addresses

    if (!eregi("^[-a-z0-9\._]+@[-a-z0-9\._]+\.+[a-z]{2,3}$"$to_email)) {

    echo(
    "You provided a improper email address!");

    }

    // the message

    mail($to_emailHelloHow are 'ya?)

    ?>
    You call it here: http://www.crazedhumor.com/taf.htm

    I can't find out what I did wrong!!! It won't mail the message...

    thanks in advance!

  2. #2
    SitePoint Member
    Join Date
    Sep 2001
    Location
    Maryland
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should probably put quotations around Hello and How are you in the subject and message fields, respectively, also, a semi-colon at the end would help, like so:

    mail($to_email,"Hello","How are 'ya?");

    HTH
    jogler

  3. #3
    VICTORY IS MINE! luchazard's Avatar
    Join Date
    May 2001
    Location
    USA
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Jogler, I'll try that now!

  4. #4
    Victory shall be mine tubedogg's Avatar
    Join Date
    Mar 2001
    Location
    Medina, OH
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually both things jogler mentioned are required.
    Kevin

  5. #5
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    mail("to_field""subject_field""message_body""From: from_who"); 
    that's the proper usage of mail()
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  6. #6
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Defender1
    PHP Code:
    mail("to_field""subject_field""message_body""From: from_who"); 
    that's the proper usage of mail()
    You don't have to include from, it is just there if you want to send a different address instead of your default one from the mail server

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  7. #7
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    bool mail (string to, string subject, string message [, string additional_headers [, string additional_parameters]])

    As Sean suggests, the third and forth arguements are optional. I just wanted to add that the forthe arguement is actually for additional headers. So people often forget that this can included a Bcc header where you can list additional recipients to be sent a copy without their address being revealed to other recipients.

    I don't know how many email addresses you can legally fit into a Bcc: header but this is they way I would do a mail out to a list using php and mail() rather than looping through lots of calls to mail() to send the mail to each recipient individually. The trick here is to make sure the email address in your "to" arguement is your email address (something like: mail-list@mydomain.com) so that that is the only address that is revealed to all your mailing list members (not some other poor member's email address).

  8. #8
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oops yea, i forgot to mention it.
    but it's usually a good idea to include who the mail is from though
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*


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
  •