Welcome, Guest
  • Author Topic: Simple Form and send the form in php  (Read 6352 times)

    anthony

    • Server what's that
    • *
    • Posts: 3
    • Flash-db Rules
      • MSN Messenger - eaoni@hotmail.com
      • View Profile
      • Email
    Simple Form and send the form in php
    « on: 01/17/02, 16:11 »
    Can someone PLEASE help with this problem.  I'm a 6month newbie to flash and have come a long way.  I am trying to send mail in flash using php.  I followed the instructions by jeff, but I must be doing something wrong.  here's the code I change from jeff's lesson and the load script in flash 5

    <?
    $ToEmail = "eaoni@hotmail.com";
    $ToName = "Anthony";
    $ToSubject = "Example Mail from SendMail Tutorial";
    $filename = "visitors.dat";
    $EmailBody = "Sent By: $FirstName\nSenders Email: $Email\nSenders Company: $Company\n\n
        Message Sent:\n$ToComments\n\nSender Heard About Site From: $HearAbout\n";

    $EmailFooter="\nThis message was sent by: $FirstName from $REMOTE_ADDR If you feel that you
        recieved this e-mail by accident please contact us at www.yourSite.com";
       
    $Message = $EmailBody.$EmailFooter;

    mail($ToName." <".$ToEmail.">",$ToSubject, $Message, "From: ".$FirstName." <".$Email.">");
    Print "_root.Mail.EmailStatus=Complete - Your mail has been sent";
    ?>

    loadVariablesNum ("snowMailPHP.php", "0", "Post");
           EmailStatus = "Sending... one Moment .. or two.. sometimes it's faster then other times";

    Flash-db

    • Administrator
    • Systems Administrator
    • *****
    • Posts: 1876
      • View Profile
      • Flash-db.com
    Re:Simple Form and send the form in php
    « Reply #1 on: 01/17/02, 17:27 »
    I'm not sure how much you have worked out after are MSN conversation but I'll go over a bit of it.


    <?
    $ToEmail = "eaoni@hotmail.com";
    $ToName = "Anthony";
    $ToSubject = "Example Mail from SendMail Tutorial";
    $filename = "visitors.dat";
    $EmailBody = "Sent By: $FirstName\nSenders Email: $Email\nSenders Company: $Company\n\n
        Message Sent:\n$ToComments\n\nSender Heard About Site From: $HearAbout\n";

    $EmailFooter="\nThis message was sent by: $FirstName from $REMOTE_ADDR If you feel that you
        recieved this e-mail by accident please contact us at www.yourSite.com";
       
    $Message = $EmailBody.$EmailFooter;

    mail($ToName." <".$ToEmail.">",$ToSubject, $Message, "From: ".$FirstName." <".$Email.">");
    Print "_root.Mail.EmailStatus=Complete - Your mail has been sent";
    ?>

    loadVariablesNum ("snowMailPHP.php", "0", "Post");
            EmailStatus = "Sending... one Moment .. or two.. sometimes it's faster then other times";

    1) Your SMTP settings where correct, and that should be working.

    2) After looking at the script and reviewing the PHP info.  The problem probably lies with a recent change in PHP after version 4.1.0.  I ran across this in one other NT server I was working on and I'm not sure why this is the case.  But it seems sometimes that even when register globals is turned on, you still need to declare your variables.  That means your following code would look like this:

    Code: [Select]

    $FirstName = $_POST["FirstName"];
    $HearAbout = $_POST["HearAbout"];
    ...
    ...
    //I did not add all of the code but the first two should give you an idea of what I mean.  

    $ToEmail = "eaoni@hotmail.com";
    $ToName = "Anthony";
    $ToSubject = "Example Mail from SendMail Tutorial";
    $filename = "visitors.dat";
    $EmailBody = "Sent By: $FirstName\nSenders Email: $Email\nSenders Company: $Company\n\n
        Message Sent:\n$ToComments\n\nSender Heard About Site From: $HearAbout\n";

    $EmailFooter="\nThis message was sent by: $FirstName from $REMOTE_ADDR If you feel that you
        recieved this e-mail by accident please contact us at www.yourSite.com";
       
    $Message = $EmailBody.$EmailFooter;

    mail($ToName." <".$ToEmail.">",$ToSubject, $Message, "From: ".$FirstName." <".$Email.">");
    Print "_root.Mail.EmailStatus=Complete - Your mail has been sent";

    Read over: http://www.php.net/release_4_1_0.php for more information.


    Their may be one or two other items to change, sometimes NT can be harder to work with in this respect then apache.  You may also want to add a simplified mail function as well such as:

    mail($ToEmail,$ToSubject, $Message, "From: $Email");

    that might help as well.
    « Last Edit: 01/17/02, 17:29 by Flash-db »
    Flash-DB

    cdogg

    • Server what's that
    • *
    • Posts: 1
    • Flash-db Rules
      • View Profile
      • Email
    Re:Simple Form and send the form in php
    « Reply #2 on: 01/17/02, 22:05 »
    I have a question about this line of code in the php file:
    Print "_root.Mail.EmailStatus=Complete - Your mail has been sent";

    I have pored over your example and searched high and low for a movie clip named 'Mail'.  I've also been searching for any other example of passing a variable from php back to flash -  to no avail.... what's the dealio here. ???  

    I understand this is the path back to the movie clip - but maybe I'm overthinking this - how is this possible?? I thought you could only use the FS command or something similar.  I've seen it working on your example - and another mail example, but I can't seem to get it to work.  My mailer sends the mail - and hangs on the 'one moment... ' message.  

    On the same note - is it possible to use php to:
    header("Location: http://www.yoursite.com");
    after the mail sends -


    any help is greatly appreciated. below is my php code:
    <?


    $recipient = "chris@arropi.net";
    $redirect = "http://www.arropi.net/";
    $date = date("m/d/Y");

    $subject = "message from arropi.net $date";

    $message = "First Name: $FirstName\n";
    $message.= "Last Name: $LastName\n";
    $message.= "E-mail: $Email\n";
    $message.= "Company: $Company\n\n";
    $message.= "Comments:\n$Comments\n\n";

    /* signature */
    $message .= "----------------------------------------\r"; //Signature delimiter
    $message .= "arropi studios";

    /* additional header pieces for errors, From cc's, bcc's, etc */
    $headers .= "From: $Email\n";
    $headers .= "X-Sender: <chris@arropi.net>\n";
    $headers .= "X-Mailer: PHP\n"; // mailer
    $headers .= "X-Priority: 1\n"; // Urgent message!
    $headers .= "Return-Path: <chris@arropi.net>\n";  // Return path for errors
    //$headers .= "bcc: chris@arropi.net";//bcc
    //$headers .= "Content-Type: text/html; charset=iso-8859-1\n"; // send as html email

    /*if(!mail($recipient, $subject, $message, $headers))
          
             {
             
             $date = date("m/d/Y");
             
             mail("chris@arropi.net", $subject, "error with arropi e-mailer on $date");
             header("Location: thankyou2.php?redirect=$redirect");
             exit();

             
             }else{
             
             */
             mail("chris@arropi.net", $subject, $message, $headers);
             print("_root.mail.EmailStatus=Complete - Your mail has been sent");
                
             
             //}   



    ?>

    Romwin

    • Server what's that
    • *
    • Posts: 35
    • Flash?... Whats Flash?
      • View Profile
      • Email
    Re:Simple Form and send the form in php
    « Reply #3 on: 01/18/02, 03:26 »
    Cdogg,

    Ok, in the tutorial, you have all the "how To" info on the left.  On the right is the Movie Clip "Movie" and nested in that movie clip are all the text variables and what ever else.  Now, if you have duplicated this form exactly then there will still be a need to add "Mail" to your print output.

    As far as your php, the only thing I can see would be change the print command to this:

    Code: [Select]
    print"_root.mail.EmailStatus=Complete - Your mail has been sent";

    same as urs except without the perenthesis surrounding it
    Romwin out...

    Flash-db

    • Administrator
    • Systems Administrator
    • *****
    • Posts: 1876
      • View Profile
      • Flash-db.com
    Re:Simple Form and send the form in php
    « Reply #4 on: 01/18/02, 17:34 »
    Ok,  Just to follow up with what romwin was explaining.  And to clearify one item.

    1st all of the form fields are located inside of a Movie Clip.  This movie Clip has the instance name of Mail.  The instance Name differs from the actual movie Clip name and is what you use in the Path when targeting or sending variables to a Movie Clip.  

    You will notice that when your working in MM Flash application that you can open up the Instance Panel.  and give your Movie Clip an Instance Name - This is where you would name the Movie Clip "Mail" or anything else.  This Instance Name is used to target the paths to variables.  In the tutorial you should be able to see that it is already named "Mail".

    You can send whatever headers you want.  Just as you would normally.  But the redirection Header is not necessary at all, Because after you send the Mail you can 1) Goto a New Frame in the Movie displaying a Thank you Message.  2) Return a Thank you message Directly to the Flash Movie that you just sent the e-mail from.

    This eliminates the need or hassle of any type of redirection.  Their really is no need for that in Flash.

    The Second Item you may find useful is that if you specify a Path in the LoadVariablesNum function you do not need to use the _root.Mail.Message=......  part.  By specifying a return path the variables will be returned to the Movie Clip you specified in the target.

    This might actually be the more correct usage of this tutorial.

    For Example in the Tutorial you could use:
    Code: [Select]
    loadVariablesNum ("snowMailPHP.php", _root.Mail, "Post"); To specify a return path for the variables - eliminating the need to print out _root.Mail.Status=..  in the php.  

    If you wanted to send and return the variables to a Movie Clip located on a nother level such as 1 or 2 you could use the same method.

    Anyways hope that helps.
    Flash-DB

    Romwin

    • Server what's that
    • *
    • Posts: 35
    • Flash?... Whats Flash?
      • View Profile
      • Email
    Re:Simple Form and send the form in php
    « Reply #5 on: 01/18/02, 22:51 »
    Thanks Jeff... as you could see it was early when i wrote that... actually late... couldnt see straight at that point. lol
    Romwin out...

    André Faca

    • Jr. Programmer
    • **
    • Posts: 67
    • AF has been here.
      • View Profile
      • Andre Faca Dot Com
    Simple Form and send the form in php
    « Reply #6 on: 01/19/02, 18:20 »
    Well , I have a question....I've followed all instructions from Jeff , but for my surprise ..... Even his original files don't work!!!

    I put it on my server and.......nothing.

    I know that this should work , because one time I already did it work. As I am a novice PHP programmer I'll not analize it 100% , but in my opinion Jeff should justify why we all have problems using this tutorial. :)

    Anyway , as I have Full File Support on my server , I guess this is a error from the script ( and not quite sure ) or from the ActionScript ( maybe that ) .

    Well my PHP code is :

    <?
    $ToEmail = "adjk@ihideitfromyou.com";

    $ToName = "ADJK Design";
    $ToSubject = "$ToSubject\nSenders"

    $EmailBody = "Sent By: $Name\nSenders Email: $Email\nSenders Company: $Company\n\nMessage Sent:\n$ToComments\n\nSenders Heard About Site From: $Where\n\nSenders URL: $URL\n\nSenders ID: $ID\n\nSenders Phone: $Phone\n\nSenders Inquiry: $Inquiry\n";

    $EmailFooter="\nThis message was sent by: $Name from $REMOTE_ADDR If you feel that you recieved this e-mail by accident please contact us at www.somesite.com";

    $Message = "$EmailBody.$EmailFooter;"

    mail($ToName." <".$ToEmail.">",$ToSubject, $Message, "From: ".$FirstName." <".$Email.">");


    Print "_root.Mail.EmailStatus=Complete - Thank you";

    ?>

    .

    Something wrong there ???
    Andre Faca - Macromedia Certified Professional
    ADJK HOST // Flash Optimized Deliverance Hosting
    www.andrefaca.com
    What is my IP Address?

    Flash-db

    • Administrator
    • Systems Administrator
    • *****
    • Posts: 1876
      • View Profile
      • Flash-db.com
    Re:Simple Form and send the form in php
    « Reply #7 on: 01/19/02, 18:33 »
    You should really Learn to copy and paste better:

    First of all:

    You forgot the semi-colon, the following Line -
    $ToSubject = "$ToSubject\nSenders"
    Shoud be:
    $ToSubject = "$ToSubject\nSenders";

    (Notice the semi-colon on the end. - Everything has to end with a semi-colon).

    Next one:
    -You put the semi-colon inside the quotes in the following line.
    $Message = "$EmailBody.$EmailFooter;"

    This should be:
    $Message = "$EmailBody.$EmailFooter";
    -Notice how the semi-colon is outside the quotes.

    Their's probably more but I didn't look over it that carefully.

    Anyways next time you can't get it to work please review the code for syntax errors.  I can't be responsible for things that you change and mess up in the process.





    Flash-DB

    André Faca

    • Jr. Programmer
    • **
    • Posts: 67
    • AF has been here.
      • View Profile
      • Andre Faca Dot Com
    Re:Simple Form and send the form in php
    « Reply #8 on: 01/19/02, 19:01 »
    Sorry , didn't mean to make u mad  :'(
    But anyway , it is working now , but you know the email status doesn't seem to work :|

    I've made some changes to the code .

    Check it out :)

    <?
    $ToEmail = "adjk@ihideitagain.com";

    $ToName = "ADJK";

    $ToSubject = "$ToSubject\nSenders";

    $EmailBody = "Sent By: $Name\nSenders Email: $Email\nSenders Company: $Company\n\nMessage Sent:\n$ToComments\n\nSenders Heard About Site From: $Where\n\nSenders URL: $URL\n\nSenders ID: $ID\n\nSenders Phone: $Phone\n\nSenders Inquiry: $Inquiry\n";

    $EmailFooter="\nThis message was sent by: $Name from $REMOTE_ADDR If you feel that you recieved this e-mail by accident please contact us at www.somesite.com";

    $Message = "$EmailBody.$EmailFooter";

    mail($ToName." <".$ToEmail.">",$ToSubject, $Message, "From: ".$Name." <".$Email.">");


    Print "_root.Mail.EmailStatus=Complete - Thank you";

    ?>

    Best Regards
    Andre Faca - Macromedia Certified Professional
    ADJK HOST // Flash Optimized Deliverance Hosting
    www.andrefaca.com
    What is my IP Address?

    Flash-db

    • Administrator
    • Systems Administrator
    • *****
    • Posts: 1876
      • View Profile
      • Flash-db.com
    Re:Simple Form and send the form in php
    « Reply #9 on: 01/19/02, 19:06 »
    Sorry about that as well, ADJK.

    About the printing the success message.  I went over that a bit in one of the above threads.  But it is probably because you either changed the Mail instance name of the Mail movie clip or are using it in a different location.


    For Example in the Tutorial you could use:
    Code: [Select]
    loadVariablesNum ("snowMailPHP.php", _root.Mail, "Post"); To specify a return path for the variables - eliminating the need to print out _root.Mail.Status=..  in the php.  

    If you wanted to send and return the variables to a Movie Clip located on a nother level such as 1 or 2 you could use the same method.

    Flash-DB

    André Faca

    • Jr. Programmer
    • **
    • Posts: 67
    • AF has been here.
      • View Profile
      • Andre Faca Dot Com
    Re:Simple Form and send the form in php
    « Reply #10 on: 01/20/02, 00:52 »
    Np for that , I also pushed the limits :|

    No problem I've done it in another way .
    and more interactive :)

    As the PHP doesn't fail e redirect the user to another keyframe saying that the operation is complete :)

    regards,
    Andre
    Andre Faca - Macromedia Certified Professional
    ADJK HOST // Flash Optimized Deliverance Hosting
    www.andrefaca.com
    What is my IP Address?

    Flash-db

    • Administrator
    • Systems Administrator
    • *****
    • Posts: 1876
      • View Profile
      • Flash-db.com
    Re:Simple Form and send the form in php
    « Reply #11 on: 01/20/02, 14:46 »
    That's actually a much better method.  Much less confusing as well.
    Flash-DB