A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: How do I host and send e-cards?

  1. #1
    Member
    Join Date
    Jun 2006
    Posts
    55

    How do I host and send e-cards?

    I came across this little tutorial -> http://www.flash-db.com/Ecards/ there is a download too with the source files.

    Tried it out and it didn't work. It uses 2 PHP scripts to write files in a text folder on the server, and then send out the emails.

    I'm 100% sure I did everything right, however I'm NOT so sure this code is valid anymore. (maybe it's not allowed anymore)

    It confirms that it does send completely, but nothing comes in the mail.

    in any case, is there a better and confirmed working tutorial out there for e-card hosting and sending?


    What do you think? Here's the PHP that sends out the email

    PHP Code:
    <?

    $CreateEcard = date(U);

    $filename = $CreateEcard.".txt";

    $ToName = stripslashes($ToName);
    $FromName = stripslashes($FromName);
    $Greeting = stripslashes($Greeting);
    $IntroMessage = stripslashes($IntroMessage);
    $EndMessage = stripslashes($EndMessage);

    $Today = (date ("l dS of F Y ( h:i:s A )",time()));

    $Created="Ecard Created on $Today";

    $EcardNum = $EcardSelect;

    $EcardText = "ToName=$ToName&ToEmail=$ToEmail&FromName=$FromName&FromEmail=$FromEmail&Greeting=$Greeting&IntroMessage=$IntroMessage&Created=$Created";


    $fp = fopen( "./dBText/$filename","w"); 
    fwrite($fp, $EcardText, 10000); 
    fclose( $fp ); 

    ######Email Card########
    ## You can change the subject and the message part around.
    ## Make sure to change the Link as stated in the Tutorial.
    ## (Change from 'someSite' to your actual site - leave the rest the same


    $ToSubject = "You have recieved a Flash Ecard from $FromName";
    $Message = "$ToName,\nYou have recieved a Flash card from $FromName. \nClick the following link to view your card:\n\n http://www.belitawilliamart.com/Ecards/SelectCard.php?EcardText=$CreateEcard&ENum=$EcardNum\n\n-----------------------------------\nHere is the message that was sent:\n$ToName,\n$Greeting\n$IntroMessage\n\n-$FromName\n\n\n-----------------------------------\nThis card was sent from www.flash-db.com/Ecards/\n\nThe Flash-dB Team.";


    ###################
    ## This line actually sends the email - you should not have to change this.

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


    ## This next line returns a success message to the movie.
    print "_root.Status=Success your Card Has Been Sent!";

    #### End #########
    ## By: Jeffrey F. Hill
    ## www.flash-db.com

    ?>
    here's the display php

    PHP Code:
    <?

    switch ($ENum) {

        case '1':
        $goto = "Ecard1.swf?EcardText=".$EcardText;
        $gotoFooter = "EcardFooter.swf?EcardText=".$EcardText."&EcardSelect=1";
        $Dimensions = "WIDTH=700 HEIGHT=525";
        $DimensionsFooter = "WIDTH=700 HEIGHT=250";
        break;

        case '2':
        $goto = "Ecard2.swf?EcardText=".$EcardText;
        $gotoFooter = "EcardFooter.swf?EcardText=".$EcardText."&EcardSelect=2";
        $Dimensions = "WIDTH=700 HEIGHT=525";
        $DimensionsFooter = "WIDTH=700 HEIGHT=250";
        break;

        case '3':
        $goto = "Ecard3.swf?EcardText=".$EcardText;
        $gotoFooter = "EcardFooter.swf?EcardText=".$EcardText."&EcardSelect=3";
        $Dimensions = "WIDTH=700 HEIGHT=525";
        $DimensionsFooter = "WIDTH=700 HEIGHT=250";
        break;

        case '4':
        $goto = "Ecard4.swf?EcardText=".$EcardText;
        $gotoFooter = "EcardFooter.swf?EcardText=".$EcardText."&EcardSelect=4";
        $Dimensions = "WIDTH=700 HEIGHT=525";
        $DimensionsFooter = "WIDTH=700 HEIGHT=250";
        break;

        case '5':
        $goto = "Ecard5.swf?EcardText=".$EcardText;
        $gotoFooter = "EcardFooter.swf?EcardText=".$EcardText."&EcardSelect=5";
        $Dimensions = "WIDTH=700 HEIGHT=525";
        $DimensionsFooter = "WIDTH=700 HEIGHT=250";
        break;
    }

    ?>
    here's the action script that is in the send button

    Code:
    on (release) {
    	if (ToName eq "") {
    		_root.Status = "Please enter the Name of the person your sending this to";
    	} else if (FromName eq "") {
    		_root.Status = "Please enter your Name";
    	} else if (ToEmail eq "") {
    		_root.Status = "Please enter the Email address your sending this to";
    	} else if (FromEmail eq "") {
    		_root.Status = "Please enter your email address";
    	} else if (Greeting eq "") {
    		_root.Status = "Please enter a greeting message";
    	} else if (IntroMessage eq "") {
    		_root.Status = "Please enter a Intro Message";
    	} else {
    		gotoAndStop (3);
    		_root.Status = "Sending Ecard - Please Hold";
    		loadVariablesNum ("SendEcard.php", 0, "POST");
    	}
    }
    Last edited by Izlude; 07-19-2009 at 04:17 PM.

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    did you have a look at the flash-db site and its forum?
    There is standard answer for the php question: nowadays you should change a php that reads like
    Code:
    $ToName = stripslashes($ToName);
    $FromName = stripslashes($FromName);
    $Greeting = stripslashes($Greeting);
    $IntroMessage = stripslashes($IntroMessage);
    $EndMessage = stripslashes($EndMessage);
    to
    Code:
    $ToName = stripslashes($_POST['ToName']);
    $FromName = stripslashes($_POST['FromName']);
    $Greeting = stripslashes($_POST['Greeting']);
    $IntroMessage = stripslashes($_POST['IntroMessage']);
    $EndMessage = stripslashes($_POST['EndMessage']);
    Likewise,
    Code:
    switch ($ENum) {
    should become
    Code:
    switch ($_GET['ENum']) {
    Also, did you look at permissions? You normally would have to change access rights on the dBText folder

    These things should make the ecard work .... once they do, please consider - for your own protection - that this code has a known weakness: the romName and FromEmail fields should be checked AT THE SERVER to not contain line returns. Unfortunately, you will probably find hundreds of mail sending examples with similar risk around the net

    Musicman

  3. #3
    Member
    Join Date
    Jun 2006
    Posts
    55
    The emails are sending out now, but the page is not displaying the cards.

    http://www.belitawilliamart.com/Ecar...48129824&ENum=

    It gets stuck trying to load.
    PHP Code:
    switch ($_GET['ENum']) { 
    I just switched to this one too, so that should be good to go. Permissions are all set and files are being written to the text folder.

    I'm going to think it's these embed codes?

    Code:
    <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
     codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
     <? print "$Dimensions";?>>
     <PARAM NAME=movie VALUE="<? print "$goto";?>"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="<? print "$goto";?>" quality=high bgcolor=#FFFFFF  <? print "$Dimensions";?> TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>
    </OBJECT>
    
    <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
     codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
     <? print "$DimensionsFooter";?>>
     <PARAM NAME=movie VALUE="<? print "$gotoFooter";?>"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="<? print "$gotoFooter";?>" quality=high bgcolor=#FFFFFF  <? print "$DimensionsFooter";?> TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>
    </OBJECT>
    Last edited by Izlude; 07-20-2009 at 06:55 PM.

  4. #4
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    another one line to be changed...
    Code:
    $EcardNum = $EcardSelect;
    should be
    Code:
    $EcardNum = $_POST['EcardSelect'];
    Musicman

  5. #5
    Member
    Join Date
    Jun 2006
    Posts
    55
    cool now the e-card appears!!! aw, but no text...

    http://www.belitawilliamart.com/Ecar...8184470&ENum=2

    the email that is sent to the inbox shows the message, but not on the actual card. ug.. im such a php loser, but I am su-poib with flash. does it have anything to do with this string?

    PHP Code:
    $EcardText "ToName=$ToName&ToEmail=$ToEmail&FromName=$FromName&FromEmail=$FromEmail&Greeting=$Greeting&IntroMessage=$IntroMessage&Created=$Created"
    something tells me I need to somehow put the $_POST function in there :S
    Last edited by Izlude; 07-21-2009 at 09:32 PM.

  6. #6
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    well, the recipe would be
    Code:
    $EcardText = "ToName={$_POST['ToName']}&ToEmail={$_POST['ToEmail']}& .... ";
    I hope this now covers all occurrences of received data

    Musicman

  7. #7
    Member
    Join Date
    Jun 2006
    Posts
    55
    Hi thanks again. Well it still didn't work, but I'm wondering if you think it's the actual cards themselves that aren't picking up the text.

    I did this part already

    loadVariablesNum ("http://www.belitawilliamart.com/Ecards/dBText/"+EcardText+".txt", 0);

    but there are 4 dynamic text fileds in the flash. each text field should have had an instance name but they never came with one. they don't even have action script in them. how are variables supposed to load onto dynamic text fields which never had any instructions or names on them in the first place?

    could that be it?

  8. #8
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    hood old loadvariables used text _variable_ names rather than _instance_ names. In the old years, this was the only way to use text fields, now it is considered old style
    Basically a variable for text field means that
    a) any changes to the var (by explicit script, or by receiving data with loadvariables) show up in the contents of the text field
    b) any changes to the text field (typing into it) automatically change the variable
    c) loadvariables sends all variables in its context (root or movieclip)

    When you switch from the old style to new one, you need to
    - add instance names and drop the variables
    - replace the loadvariables by loadvars calls
    - add one line of code for every var that should be sent from the server

    Musicman

  9. #9
    Member
    Join Date
    Jun 2006
    Posts
    55
    everything is working! thank you so much for your help. although i sinned a little and enabled the register globals... eventually i'll figure out a script that doesn't rely on them, but for now i'll finally get some work done on actually making the cards now.

  10. #10
    Registered User
    Join Date
    Aug 2009
    Posts
    1
    Hey! This forum has been VERY helpful! I also am working from the same www.flash-db.com/Ecards tutorial. Everything seems to be working properly except for the text message showing up when you play the greeting. Musicman I see that you were able to give Izlude some suggestions on how to fix their problem, and they seem to have picked up on what you were saying. I unfortunately, don't get it. Can you break it down into more simple terms?

    For example, can you provide a written example of what you mean by changing out the instance names and dropping the variables, replacing the loadvariables with loadvars that then adding the one line of code for every var? I was following you up until that point.

    Thanks so much!

  11. #11
    Member
    Join Date
    Jun 2006
    Posts
    55
    Hi Holly. Don't worry about adding "instance" names to the dynamic text fields in the e-cards. That was a mistake on my part. I'm just used to newer dynamic text loading which is not needed by this tutorial. The dynamic text fields (from the zip) already have the variable names filled out for you, so there's no need to touch them.

    If the texts appear properly in the email but not the e-card, then you need to turn the register globals "on" (in php settings) For my situation, I had to upload a file called .htaccess with the following line:

    php_flag register_globals 1

    It's an invisible file in the root documents folder. It should be in ANSI format (not unicode or UTF) so after uploading it, you won't see it on your list, but it IS indeed there. People say it's a security risk, but I'm going to deal with it myself anyway.

    My only peev with this whole flash ecard tutorial is that they end up in the junk folder because using the "FromEmail" is not domainkeys complient. I'll have to fix that later and share it on here. If you still have problems, I'll share my current code with you and then you can compare.
    Last edited by Izlude; 08-10-2009 at 09:14 PM.

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