A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 35

Thread: php novice : without a clue

  1. #1

    php novice : without a clue

    OK, please don't laugh, but: I'm trying to learn-

    I am tying a .swf form I created, with php, based on a tutorial I found.

    The script for the php end was simply written in a text editor. I'm ready to test. What do I need to do to convert the .txt file to the correct format so that it actually will perform as intended?

    Thanks

  2. #2
    Special Member Tea_J's Avatar
    Join Date
    Dec 2000
    Posts
    991
    hey there.. umm.. judging by your question, i hope you programmed the *.txt file right.

    well, chaning a script to an executable format isnt really that hard.. actually, all ya have to do is RENAME it from script.txt to script.php (if ur coding a php script) ..also, make sure that you have your Explorer View Options set properly so you can access file extensions.. cause no matter how you rename it with .php like script.txt - script.php, it will remain actually remain a txt file and the real name will be script.php.txt ...


    go to your explorer
    1) tools>folder options>
    2) then click on the "View" tab
    3) under the Files and Folders list, UNCHECK the "Hide file extensions for...."

    hope this helps

    tea

  3. #3
    Hey, thank you for responding!

    I to hope the script is correct!

    I was a bit confused for a sec. That’s because I didn't read all of your response.

    I'm clear now!

    Again, thanks!
    Last edited by hothousegraphix; 04-24-2003 at 04:26 PM.

  4. #4
    Sorry to bother, I was wondering is you might be able to take a look?

    Targeting issue - from PHP novice
    I'm sure this is a targeting issue:

    CODE:
    <?
    $ToEmail = "info@hothousegraphix.com";

    ##$ToName = "hothousegraphix";
    $ToSubject = "QUOTE REQUEST";

    $EmailBody = "Sent By: $CompanyContact\nSenders Email: $CompanyEmail\nSenders Company: $CompanyName\nSenders Company Website: $CompanyWebsite\nSenders Phone: $CompanyPhone\nSenders Fax: $CompanyFax\nSenders Street Address: $CompanyStreet\nSenders City: $CompanyCity\nSenders State: $CompanyState\nSenders Zip: $CompanyZip\n

    \nMessage Sent:\n$ProjectScope\nTarget Base: $ProjectTarget\n\nProject Discription: $ProjectDiscription\n\nProject budget: $ProjectBudget\nProjectCompletion: $ProjectCompletionDate\n\nProject Other: $ProjectOther\n";

    $EmailFooter="\nThis message was sent by: $CompanyContact from $CompanyName ($CompanyEmail) If you feel that you recieved this e-mail in error, please contact us at www.hothousegraphix.com";

    $Message = $EmailBody.$EmailFooter;

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


    Print "_root.Mail.EmailStatus=Complete - YOUR QUOTE REQUEST HAS BEEN RECEIVED";

    ?>


    Everything above works just fine with the exception of the last command:

    Print "_root.Mail.EmailStatus=Complete - YOUR QUOTE REQUEST HAS BEEN RECEIVED";


    The targeted .swf is imbedded in an .html page.
    My Script.php and that .html file live in the same directory. I'm sure my problem is that I've imbedded the .swf.

    How would I target?

    Also, can I perform the mail function twice with different variables?
    I want to be able to "CC" the request back to the senders e-mail address along with a short message.

    I've tried adding to the above script:

    $CCSubject= "blah blah blah";
    //as well as//
    $CCMessage= "blah blah blah";
    //then an additional mail function<sorry if this is the wrong term//
    mail($CompanyContact." <".$CompanyEmail.">,$CCSubject,$CCMessage,$ToName, <".$ToEmail.">);


    These additions don't seem to work.

    I realize there are several questions here...any help is welcome!!!

    Any thoughts?

    Thanks!

  5. #5
    __OSX powered__ nucleuz's Avatar
    Join Date
    Aug 2000
    Location
    Norway
    Posts
    836
    I think you should read up on http://www.php.net/manual/en/function.mail.php on the mail() function, there are some examples on how to do CC there.

    http://lwest.free.fr/doc/php/lib/ind...e=mail&lang=en is also a nice class for doing mail!

    Have a search on google for "php mail CC tutorial", that should give you some more clues on how this works!

    Good luck!
    NuCleuZ :: PHPVolcano :: Blog

  6. #6
    Thank you for the info.

  7. #7
    Official FK nice guy and MOD 3PRIMATES's Avatar
    Join Date
    Apr 2002
    Location
    Portland Oregon
    Posts
    1,645
    Hi there..

    Although most of the scripting is valid, I do see a few things that are going to cause you problems.

    There is no error checking
    The variables being passed from flash are not declared.

    Here is your modified script with the CC return message, simple error check, and a few other bells and whistles.

    This does work using the test variables at the top, but I didnt want to recreate a flash form to test that..

    I hope it helps..

    PHP Code:
    <?php

    // mail user address user will respond to in the CC
    $CC_mail "info@hothousegraphix.com";
    $CC_from "Hot House Graphics";
    $CC_subject "Request Recieved";

    // Info used on mail to admin
    $ToEmail "info@hothousegraphix.com";
    $ToName "hothousegraphix";
    $ToSubject "QUOTE REQUEST";


    ## START OUTPUTING FORMATED POST VARIABLES
    ## putting your form variables into an array
    $postvars = array("CompanyName""CompanyEmail""CompanyContact",
    "CompanyWebsite""CompanyPhone""CompanyFax""CompanyStreet",
    "CompanyCity""CompanyState""CompanyZip","ProjectTarget",
    "ProjectDiscription""ProjectBudget""ProjectCompletionDate",
    "ProjectOther""ProjectScope");

    ## each item in the array is output as a post variable
    ## example: CompanyName above is now $_POST['CompanyName'];
    ## This is done to comply with PHPs new security features
    foreach ($postvars as $var)
    if(isset(
    $_POST[$var]))
    $
    $var $_POST[$var];

    ## END OUTPUT POST

    /*
    // variables sent from flash
    // NOTE: These variables have been put into an array above and
    // are only used here for script testing purposes
    $CompanyName = "Some Company name";
    $CompanyEmail = "pathfinder@joinedlight.com";
    $CompanyContact  = "CompanyContact";
    $CompanyWebsite  = "CompanyWebsite";
    $CompanyPhone  = "CompanyPhone";
    $CompanyFax  = "CompanyFax";
    $CompanyStreet  = "CompanyStreet";
    $CompanyCity  = "CompanyCity";
    $CompanyState  = "CompanyState";
    $CompanyZip  = "CompanyZip";

    $ProjectTarget  = "ProjectTarget";
    $ProjectDiscription  = "ProjectDiscription";
    $ProjectBudget = "ProjectBudget";
    $ProjectCompletionDate  = "ProjectCompletionDate";
    $ProjectOther = "ProjectOther";
    $ProjectScope = "ProjectScope";
    */


    ## 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 to print on email
    $date date("l dS of F Y h:i:s A");



    ## START ADMIN MESSAGE
    $EmailBody "Sent By: $CompanyContact\nSenders Email: $CompanyEmail\nSenders Company: $CompanyName\n
    Senders Company Website: 
    $CompanyWebsite\nSenders Phone: $CompanyPhone\nSenders Fax: $CompanyFax\n
    Senders Street Address: 
    $CompanyStreet\nSenders City: $CompanyCity\nSenders State: $CompanyState\n
    Senders Zip: 
    $CompanyZip\n\nMessage Sent:\n$ProjectScope\nTarget Base: $ProjectTarget\n\n
    Project Discription: 
    $ProjectDiscription\n\nProject budget: $ProjectBudget\n
    ProjectCompletion: 
    $ProjectCompletionDate\n\nProject Other: $ProjectOther\n\n";
    $EmailFooter="Date: $date\nSenders Host Address: $REMOTE_ADDR\nSenders IP Address: $ip";
    $Message $EmailBody.$EmailFooter;
    ## END ADMIN MESSAGE

    ## START CLIENT MESSAGE
    $CC_emailbody "Thank you $CompanyContact, for filling out our request form.\n
    We will be contacting you as soon as possible with further details\n\n
    The 
    $CC_from team";

    $CC_emailfooter="\nThis message was sent by: $CompanyContact from $CompanyName ($CompanyEmail) If you feel that you recieved this e-mail in error, please contact us at www.hothousegraphix.com";
    $CC_message $CC_emailbody.$CC_emailfooter;
    ## END CLIENT MESSAGE

    ## SEND MAIL or DIE and return error message to flash for processing
    mail($ToName." <".$ToEmail.">",$ToSubject$Message"From: ".$CompanyContact." <".$CompanyEmail.">") or die ("&mail_error=yes");
    mail($CompanyContact." <".$CompanyEmail.">",$CC_subject$CC_message"From: ".$CC_from." <".$CC_mail.">") or die ("&mail_error=yes");
    Print 
    "&mail_error=no&EmailStatus=Complete - YOUR QUOTE REQUEST HAS BEEN RECEIVED";
    ?>
    The variables are being sent to the _root timeline. In order to access
    them you will need to call the absolute path from the movie that contains your mail functions
    If you need the variables data in a movie clip called mailMC on the _root timeline, you would call the vars with _root.mail_error
    from that clip.

    You will need a loop to run in your movie while the mail is being sent. The loop should look for the returned variable mail_error
    Here is an actionscript sample:
    PHP Code:
    // ActionScript
    // Point your submit button to a frame with this code
    // It is a self contained loop and will run until one
    // of the if statements return true
    // It would be a good idea to add some kind of timeout function
    // that will time out the movie if the php script fails for some reason.

    stop();
    //The date function just keeps the script from being cached
    loadVariablesNum("mail_test2.php?nocache=" + new Date().getTime(),  0"POST");
    // the loop
    this.onEnterFrame=function(){
        if(
    _root.mail_error == "yes"){
        
    _gotoAndPlay("mail_error_frame");
        
    delete this.onEnterFrame;
        }
            if(
    _root.mail_error == "no"){
        
    _gotoAndPlay("mail_success_frame");
        
    delete this.onEnterFrame;
        }


    3PRIMATES
    Last edited by 3PRIMATES; 04-25-2003 at 02:38 PM.

  8. #8
    WOW! Thanks for the help!!!

    Where to begin???

    I'm understanding most of whats going on in you script update. A few questions:

    1) will the "//" and "##" be ignored, or do these comments need to be stripped?

    2)The variables stated from flash for the purpose of testing, do these items stay in the script placed on my server?

    3)The below section:

    ## 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 to print on email
    $date = date("l dS of F Y h:i:s A");

    I'm not quite understanding the purpose, other than the posting of the date---???

    Again, thanks!!!!

  9. #9
    Official FK nice guy and MOD 3PRIMATES's Avatar
    Join Date
    Apr 2002
    Location
    Portland Oregon
    Posts
    1,645
    Hi,

    1) will the "//" and "##" be ignored, or do these comments need to be stripped?
    Yes // and # are for comments and DO NOT need to be removed. They are ignored by PHP. Here are some examples:
    PHP Code:
    // this is a single line comment

    # This is another type of single line comment, works the same as above

    /*
    This is a multiline comment, 
    and anthing between these tags will not be parsed by PHP.
    */ 

    2)The variables stated from flash for the purpose of testing, do these items stay in the script placed on my server?
    No it does not..I left it in but commented it out just in case you wanted to test the script by itself without the flash form.

    3)The below section:

    ## 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 to print on email
    $date = date("l dS of F Y h:i:s A");

    I'm not quite understanding the purpose, other than the posting of the date---???
    The REMOTE_address stuff prints the users ip and host on the form that is sent to you..Just in case someone trys to use the form for other purposes, and for debugging.

    The date is just the date of the mail sent.. Its just a lil extra sent to you in the response.

    Again, this is a working form..

    Hope it helps

    3PRIMATES

  10. #10
    Again thank you!

    It's not often one is able to receive such comprehensive help!

    Thanks!

  11. #11
    Just tested,

    The sending of both the Admin and CC massages works wonderfully.

    The returning of confirmation variables to flash is not working.

    Several things:

    First - shouldn't I be spelling out the entire path to the "EmailStatus" text field in my mail MC?
    //you show the following at the end of the php script
    Print "&mail_error=no&EmailStatus=Complete - YOUR QUOTE REQUEST HAS BEEN RECEIVED";

    //Shouldn't I have the path to that field spelled out e.g.:
    Print "&mail_error=no&_root.mail.EmailStatus=Complet e - YOUR QUOTE REQUEST HAS BEEN RECEIVED";

    Also, I'm assuming you intend for the underscores to be removed from the
    _gotoAndPlay("mail_error_frame");


    The actionScript loop shows that I should have both a "mail_error_frame" as well as a "mail_success_frame" which I have included. In each frame I've also stated the variable EmailStatus to read mail error and mail success respectivily. These seems be in conflict with what is scripted in the php.

    If you would,

    Could You take a look at this for me?

    Many Thanks!!!
    Last edited by hothousegraphix; 04-26-2003 at 03:42 PM.

  12. #12
    Official FK nice guy and MOD 3PRIMATES's Avatar
    Join Date
    Apr 2002
    Location
    Portland Oregon
    Posts
    1,645
    Hi,
    I just tested your movie and script on my server and it worked perfectly..
    The mail sent, the status message was the completed message, and I recieved 2 emails.

    I did see 2 problems though in your movie:
    The loadVarialbes line needs to be removed from the submit button because the variables are being loaded in frame 2.

    You need to clear your form fields if the submission was a success.
    Just make all the variables blank on the mail_success_frame.
    myVar = "";
    myVar2 = "";

    etc, etc..
    The above will keep people from pressing the button over and over.


    You can remove the
    EmailStatus = "Blah blah blah";
    in the error and success frames and replace it with this:
    EmailStatus = _root.EmailStatus;

    This will call the message that was sent by PHP on error or success..

    What problems were you having>?

    Im leaving until monday,
    but keep posting your problems in here and I will address them all on monday..

    3PRIMATES

  13. #13
    Thanks for taking a look!

    The problem I was having was the the EmailStatus field remained stuck on

    "SUBMITTING QUOTE REQUEST...";

    after pressing submit

    It does send the two e-mails, but the FLASH form is not recieving the error or success messages from the php.
    Last edited by hothousegraphix; 04-26-2003 at 04:47 PM.

  14. #14
    Official FK nice guy and MOD 3PRIMATES's Avatar
    Join Date
    Apr 2002
    Location
    Portland Oregon
    Posts
    1,645
    Hi,
    when I just tested the script, it worked for me.

    Im not usre what to tell you right now, but Ill look again when I get back..
    Keep posting your questions..

    3PRIMATES

  15. #15
    Thanks

  16. #16
    I'm pissed now!

    I had everything working up to the swf receiving the variables passed from php back to FLASH which were to move the mailMC to either the "mail_Error_Frame", or the "mail_Success_Frame". The form was recieving the confimation statement sent by php to the EmailStatus text field. I found that the path in php needed to be changed from
    Code:
    Print "&mail_error=no&EmailStatus=Complete - YOUR QUOTE REQUEST HAS BEEN RECEIVED";
    
    //Changed to
    
    Print "&mail_error=no&_root.mail.EmailStatus=Complete - YOUR QUOTE REQUEST HAS BEEN RECEIVED";
    NOW NOTHING IS WORKING!!!!!

    I have no idea what I've done! I'm lost.

    I have checked with my HOST to see if this might have been a result from something on there end.

    Do you have a suggestion for a program that will allow me to test locally without having to upload to my server? Someone provided me a link to:
    http://www.sokkit.net/
    and
    http://www.activestate.com/Products/Komodo/

    Your thoughts?

    Again THANKS!

  17. #17
    OK...I've gotten back to where I was prior to this snag!!!

    I did this by first going back to the script I had prior to using the updated php script - this to determine whether or not there was a problem with the server.

    No server problem.

    I then simply went back to square one with the updated php. With the action script I decided to leave out the loop until I was sure that php was receiving all variables from FLASH, and then executing the mail function < this is up and running again.

    Now to the sending of variables back to FLASH (the confirmation message) this was not working. As I stated in my prior post - I noticed that the path to EmailStatus text field was incorrect -
    I made the necessary change and this now is working.

    I am now beginning to re-implement the loop in FLASH, as well as,
    try to get the script correct for calling on the variables passed from php - for moving the FLASH MC to either the mail_error_frame, or the mail_success_frame < I think this is what's been creating the problems I've been experiencing. I'm not sure what I need to do to correct this but I'm wondering if this too is a path issue.

    The variables should be sent to my MC "mail" (_root.mail).

    I'll let you know what comes of my tinkering!

    Again, THANKS!
    Last edited by hothousegraphix; 04-27-2003 at 07:15 PM.

  18. #18
    Here's what I'm experiencing!

    When I implement the actionScript loop (that checks for the mail_error variables sent from php) in my QuoteForm.swf, everything stops working. None of the php functions are performed. I have no Idea why this is.

    I then eliminated the loop altogether. This left the button action on(release)sending my mailMC to frame 2 which simply had a stop and loadVariables action:
    Code:
    stop();
    loadVariablesNum("mail_test2.php?nocache=" + new Date().getTime(),  0, "POST");
    For some reason, this didn't work either. I then moved the loadVariables action to the submit button action on(release).
    This also didn't work. I then returned to the following at on(release):
    Code:
    loadVariablesNum ("snowMailPHP.php", "0", "Post");
    EmailStatus = "SUBMITTING QUOTE REQUEST...";
    gotoAndPlay("mail_success_frame")//where all text variables are cleared
    THIS WORKS

    I realize I'm ignoring any mail_error variables sent from php.
    But, at this point, at least it's working!

  19. #19
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    should be more like that:
    1st frame is form with submit button - movie is stopped, so button action sets status, then does loadvaribles and play
    2nd frame - no code
    3rd frame - if status still the same, go to 2nd frame, otherwise show success or failure

    Musicman

  20. #20
    I'm still wondering about how to retrieve the mail_error variables passed from php to my FLASH form. These were supposed to be the triggers my actionScript loop was looking for and that send my mailMC to either the mail_error_frame, or mail_success frame.

    Currently, if there happens to be a mail_error sent from php the FLASH form is not set up to receive.

    Shouldn’t I be able to set this up the same the confirmation message is sent from php?
    PHP Code:
    ## ## SEND MAIL or DIE and return error message to flash for processing
    mail($ToName." <".$ToEmail.">",$ToSubject$Message"From: ".$CompanyContact." <".$CompanyEmail.">") or die ("&mail_error=yes");
    mail($CompanyContact." <".$CompanyEmail.">",$CC_subject$CC_message"From: ".$CC_from." <".$CC_mail.">") or die ("&mail_error=yes");
    Print 
    "&mail_error=no&EmailStatus=Complete - YOUR QUOTE REQUEST HAS BEEN RECEIVED";
    ?> 
    If I simply had a Print function for $mail_error=yes, something like:
    PHP Code:
    Print "$mail_error=yes$EmailStatus=An error occured with you submition. Please re-submit";?> 
    Will php be able to discern between each instance, or, is this going to create a bottle-neck because php will try to send both at the same time?

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