A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: php mail problems

  1. #1
    Member
    Join Date
    Mar 2002
    Posts
    68

    php mail problems

    hello i have thsi script and it is not working for me. i know php works because when i use a simpler emailer it works fine what am i doing wrong here. I have had this working before and i just changed some stuff and now it is not working. also if anyone could explain the mail() function in php like if i was 10. well thanks for reading. Patrick



    <?

    $recipient = "downwash@oberon.ark.com";
    $subject = "Swedish Design Order";
    $mailheaders = "From: <$lastname> \n";
    $mailheaders .= "Reply-To: <$email>\n\n";

    $msg = "Swedish Design Order Number: $serial\n";
    $msg .= "\n\n";
    $msg .= "Sender's First Name: $firstname\n";
    $msg .= "\n";
    $msg .= "Sender's Last Name: $lastname\n";
    $msg .= "\n";
    $msg .= "Address: $address\n";
    $msg .= "\n";
    $msg .= "City: $city\n";
    $msg .= "\n";
    $msg .= "Province/State: $province\n";
    $msg .= "\n";
    $msg .= "Country: $country\n";
    $msg .= "\n";
    $msg .= "Zip Code: $zip\n";
    $msg .= "\n";
    $msg .= "Area Code Is: $areaphone\n";
    $msg .= "\n";
    $msg .= "Phone Number is: $phone\n";
    $msg .= "\n";
    $msg .= "Sender's E-Mail: $email\n";
    $msg .= "\n";
    $msg .= "Senders IP Address: $REMOTE_ADDR"
    $msg .= "_________________________________________________ ____________________";

    mail($recipient,$ToSubject,$Message,$mailheaders);

    ?>

  2. #2
    Member
    Join Date
    Mar 2002
    Posts
    68
    oh sorry, bottom part was wrong a bit but it still won't work with this.



    <?

    $recipient = "downwash@oberon.ark.com";
    $subject = "Swedish Design Order";
    $mailheaders = "From: <$lastname> \n";
    $mailheaders .= "Reply-To: <$email>\n\n";

    $msg = "Swedish Design Order Number: $serial\n";
    $msg .= "\n\n";
    $msg .= "Sender's First Name: $firstname\n";
    $msg .= "\n";
    $msg .= "Sender's Last Name: $lastname\n";
    $msg .= "\n";
    $msg .= "Address: $address\n";
    $msg .= "\n";
    $msg .= "City: $city\n";
    $msg .= "\n";
    $msg .= "Province/State: $province\n";
    $msg .= "\n";
    $msg .= "Country: $country\n";
    $msg .= "\n";
    $msg .= "Zip Code: $zip\n";
    $msg .= "\n";
    $msg .= "Area Code Is: $areaphone\n";
    $msg .= "\n";
    $msg .= "Phone Number is: $phone\n";
    $msg .= "\n";
    $msg .= "Sender's E-Mail: $email\n";
    $msg .= "\n";
    $msg .= "Senders IP Address: $REMOTE_ADDR"
    $msg .= "_________________________________________________ ____________________";

    mail($recipient,$subject,$msg,$mailheaders);

    ?>

  3. #3
    Member
    Join Date
    Mar 2002
    Posts
    68
    sorry but there were some little error but it still won't work.





    <?

    $recipient = "downwash@oberon.ark.com";
    $subject = "Swedish Design Order";
    $mailheaders = "From: <$lastname> \n";
    $mailheaders .= "Reply-To: <$email>\n\n";

    $msg = "Swedish Design Order Number: $serial\n";
    $msg .= "\n\n";
    $msg .= "Sender's First Name: $firstname\n";
    $msg .= "\n";
    $msg .= "Sender's Last Name: $lastname\n";
    $msg .= "\n";
    $msg .= "Address: $address\n";
    $msg .= "\n";
    $msg .= "City: $city\n";
    $msg .= "\n";
    $msg .= "Province/State: $province\n";
    $msg .= "\n";
    $msg .= "Country: $country\n";
    $msg .= "\n";
    $msg .= "Zip Code: $zip\n";
    $msg .= "\n";
    $msg .= "Area Code Is: $areaphone\n";
    $msg .= "\n";
    $msg .= "Phone Number is: $phone\n";
    $msg .= "\n";
    $msg .= "Sender's E-Mail: $email\n";
    $msg .= "\n";
    $msg .= "Senders IP Address: $REMOTE_ADDR"
    $msg .= "_________________________________________________ ____________________";

    mail($recipient,$subject,$msg,$mailheaders);

    ?>

  4. #4
    Member
    Join Date
    Mar 2002
    Posts
    68
    does anyone know??? i am really confused by this

  5. #5
    Senior Member
    Join Date
    Nov 2002
    Location
    SA
    Posts
    234

    here you go...

    hi there, you firstly need to read some tutorials on flash php as there are many a error in your script, after reading the script take a look at my comments at the bottom for comments.

    ____________________________________

    <?php

    if (($serial == "") || ($firstname == "") || ($lastname == "") || ($address == "") || ($city == "") || ($province == "")) {
    header("Location: ");
    exit;
    }

    if ($REMOTE_ADDR == "") $ip = "no ip";
    else $ip = getHostByAddr($REMOTE_ADDR);

    $recipient = "downwash@oberon.ark.com";
    $subject = "Swedish Design Order";
    $mailheaders = "From: <$lastname> \n";
    $mailheaders .= "Reply-To: <$email>\n\n";

    $msg = "Swedish Design Order Number: $serial\n";
    $msg .= "Sender's First Name: $firstname\n";
    $msg .= "Sender's Last Name: $lastname\n";
    $msg .= "Address: $address\n";
    $msg .= "City: $city\n";
    $msg .= "Province/State: $province\n";
    $msg .= "Country: $country\n";
    $msg .= "Zip Code: $zip\n";
    $msg .= "Area Code Is: $areaphone\n";
    $msg .= "Phone Number is: $phone\n";
    $msg .= "Sender's E-Mail: $email\n";
    $msg .= "Senders Host Address: $REMOTE_ADDR\n";
    $msg .= "Senders IP Address: $ip\n\n;

    mail($recipient,$subject,$msg,$mailheaders) or die ("couldn't send mail");

    ?>
    ____________________________________________

    Why your script didn't work...

    1) you missed the top lines of code. also finish adding in the rest of the varible names, eg.( if (($serial == "") )
    this makes sure that the variables that are being sent to flash have a value.

    2) $REMOTE_ADDR does not get the ip address, it is the isp's info, so that is why i added the coding to $REMOTE_ADDR and your $msg.

    3) your format was wrong in the $msg areas, as you can see i removed unwanted lines.

    4) you should also attach a date function so you can see when the mail was sent.


    cya
    protocol

  6. #6
    Member
    Join Date
    Mar 2002
    Posts
    68
    hey thanks alot. yeh i am looking for a good book to learn from in our library because i have only used action dcripting which i like to think i am good at. i just get stuck learning new things. well thanks again you really helped. Patrick

  7. #7
    Senior Member
    Join Date
    Nov 2002
    Location
    SA
    Posts
    234

    np

    no prob, i am not used to php also, but have looked over many a code and after a while it gets easier, here is a link to some flash php tutorials if your interested...

    http://www.sephiroth.it/tutorials/flashPHP/

    if you know of any other tutorials available please tell me as i find it hard to find good tutorial, unless you can speak german or french that is

    cya
    protocol

  8. #8
    Member
    Join Date
    Mar 2002
    Posts
    68
    sorry to say but that script does not work.

    Now i am really comfused. if there a limmit on how mnay workd you can have in it because my little cript worked just fine. Thanks for the link but, most of it was way too complicated.

  9. #9
    Now listen heah! Mac8myPC's Avatar
    Join Date
    Aug 2000
    Location
    Steve Job's Doorstep
    Posts
    695
    you're script was workable.. it just had a couple of syntax errors.

    you might have to add 'php' to the opening tag in order for your ISP's server to parse the file correctly..

    <?php

    and you missed a semi-colon on this line..

    $msg .= "Senders IP Address: $REMOTE_ADDR"

    protocol's script added some good features such as verifying that there was data and verifying the remote IP.. but with the two changes above your script should at least mail and give you the input your looking for...

  10. #10
    Official FK nice guy and MOD 3PRIMATES's Avatar
    Join Date
    Apr 2002
    Location
    Portland Oregon
    Posts
    1,645
    Hello,
    here is an addition to what protocal supplied..

    This code is from Musicmans sticky within this forum..
    PHP's new security for passing of variables means that you must declare the variable that is being passed(PHP 4.1 and above), or the script will fail..

    I think I have this right, but it might be a good idea to look into this:

    PHP Code:

    <?php

    $postvars 
    = array("serial""firstname""lastname""address""city""province");
    foreach (
    $postvars as $var)
    if(isset(
    $_POST[$var]))
    $
    $var $_POST[$var];

    if ((
    $serial == "") || ($firstname == "") || ($lastname == "") || ($address == "") || ($city == "") || ($province == "")) {
    header("Location: ");
    exit;
    }

    if (
    $REMOTE_ADDR == ""$ip "no ip";
    else 
    $ip getHostByAddr($REMOTE_ADDR);

    $recipient "downwash@oberon.ark.com";
    $subject "Swedish Design Order";
    $mailheaders "From: <$lastname> \n";
    $mailheaders .= "Reply-To: <$email>\n\n";

    $msg "Swedish Design Order Number: $serial\n";
    $msg .= "Sender's First Name: $firstname\n";
    $msg .= "Sender's Last Name: $lastname\n";
    $msg .= "Address: $address\n";
    $msg .= "City: $city\n";
    $msg .= "Province/State: $province\n";
    $msg .= "Country: $country\n";
    $msg .= "Zip Code: $zip\n";
    $msg .= "Area Code Is: $areaphone\n";
    $msg .= "Phone Number is: $phone\n";
    $msg .= "Sender's E-Mail: $email\n";
    $msg .= "Senders Host Address: $REMOTE_ADDR\n";
    $msg .= "Senders IP Address: $ip\n\n;

    mail(
    $recipient,$subject,$msg,$mailheaders) or die ("couldn't send mail");

    ?>
    I hope it helps..
    3PRIMATES

  11. #11
    Senior Member
    Join Date
    Nov 2002
    Location
    SA
    Posts
    234

    i was wondering about

    thanks for adding to the code 3PRIMATES, i will use it to update my script. currently the script is working fine so if i change it by adding these lines will it still work ???

    btw, does anyone know more commands for the mail form, if so add them to the code, it would be a great way for others to learn...

    cya
    protocol

  12. #12
    Member
    Join Date
    Mar 2002
    Posts
    68
    hello, i am sorry to bother you huys but it still does not work. i have made the file a while ago and i am bringing it back to life. why would the script not work. here is the fla and the php that i am usiing
    Attached Files Attached Files

  13. #13
    Official FK nice guy and MOD 3PRIMATES's Avatar
    Join Date
    Apr 2002
    Location
    Portland Oregon
    Posts
    1,645
    Hi, Im so sorry..
    I found some syntax errors later..

    I have gone ahead and added a few more bells and whistles to this..
    this should work, but if you are still having problems let me know..

    Use the attached file, dont copy and paste from this message:

    PHP Code:
    <?php
    ## putting your form variables into an array
    $postvars = array("serial""firstname""lastname""address""city""province""country""zip""areaphone""phone""email");
    foreach (
    $postvars as $var)
    ## each item in the array is output as a post variable
    ## example: serial above is now $_POST['serial'];
    if(isset($_POST[$var]))
    $
    $var $_POST[$var];

    ## error message option 1: error message redirect
    ## uncomment lines below, create mail_error.htm and comment out option 2 to use
    #if (($serial == "") || ($firstname == "") || ($lastname == "") || ($address == "") || ($city == "") || ($province == "")) {
    #header("Location:mail_error.htm");
    #exit;
    #}

    ?>

    <html>
    <head>
    <title>
    Swedish Design Order: Contact Us
    </title>
    </head>
    <body>
    <font face="geneva,arial,helvetica" size=1>
    <table width="100%" height="100%" bgcolor="#eeeeee">
    <tr>
    <td align="center" valign="middle">
    <table width="30%" bgcolor="#444444" cellpadding="2" cellspacing="2">
    <tr>

    <?php

    ## error message option 2: self contained error message
    ## comment out 4 lines below if using option 1
    if (($serial == "") || ($firstname == "") || ($lastname == "") || ($address == "") || ($city == "") || ($province == "")) {
    echo 
    "<td bgcolor='8C96D3'><b>Incomplete Data:</b><br>Please fill in all required fields and try again</td>";
    exit;
    }

    ## retreiving the users ip address if available, if not available  $ip = no ip
    if ($REMOTE_ADDR == ""){
    $ip "no ip";
    }
    else
    {
    $ip getHostByAddr($REMOTE_ADDR);
    }
    ## date printed on email
    $date date("l dS of F Y h:i:s A");

    $recipient "downwash@oberon.ark.com";
    $subject "Swedish Design Order";
    $mailheaders "From: <$lastname> \n";
    $mailheaders .= "Reply-To: <$email>\n\n";

    $msg "Swedish Design Order Number: $serial\n";
    $msg .= "Sender's First Name: $firstname\n";
    $msg .= "Sender's Last Name: $lastname\n";
    $msg .= "Address: $address\n";
    $msg .= "City: $city\n";
    $msg .= "Province/State: $province\n";
    $msg .= "Country: $country\n";
    $msg .= "Zip Code: $zip\n";
    $msg .= "Area Code Is: $areaphone\n";
    $msg .= "Phone Number is: $phone\n";
    $msg .= "Sender's E-Mail: $email\n";
    $msg .= "Senders Host Address: $REMOTE_ADDR\n";
    $msg .= "Date: $date\n";
    $msg .= "Senders IP Address: $ip\n\n";

    ## The @ character in front of mail function supresses any php error messages that would be output to the user
    @mail($recipient,$subject,$msg,$mailheaders) or die ("<td bgcolor='C8010D'><b>Mail server error:</b><br>We are sorry, your mail could not be sent at this time.<br> If you continue to recieve this error, please contact the <a href='mailto:$recipient'>webmaster</a></td>");
    ?>

    </tr>
    </table>
    </td>
    </tr>
    </table>
    </font>
    </body>
    </html>
    Hope it works for you

    3primates
    Attached Files Attached Files

  14. #14
    Official FK nice guy and MOD 3PRIMATES's Avatar
    Join Date
    Apr 2002
    Location
    Portland Oregon
    Posts
    1,645
    Hi,
    there is a syntax error in your form here:
    $msg .= "Senders IP Address: $ip\n\n;

    it should read:
    $msg .= "Senders IP Address: $ip\n\n";

    Notice that you were missing and ending quote mark.

    That should fix your problem

    3PRIMATES

  15. #15
    Member
    Join Date
    Mar 2002
    Posts
    68
    hey thank you guys so much. It WORKS. I am so happy. now i can spiff up the order from. i learned so much from you guys. thanks again. Patrick

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center