A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: I need help in creating a guestbook from scratch

  1. #1
    Junior Member
    Join Date
    Oct 2008
    Posts
    16

    Question I need help in creating a guestbook from scratch

    Hi all, Please help me .... I am creating a wedding website in flash cs6 with as2.0 for which i need to create a guestbook with 4 fields - first name, last name, email, message. On clicking the submit button I want these information to be sent to my email.
    I really don't have any idea how to do it. can someone please guide me in this. link to a detailed tutorial will also help. or if someone of you can share a fla file with a guestbook it will be so helpful.
    I know nothing about php and all.. so pls explain in detail...
    Pls help me guys..Thankyou so much.

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Hi,

    If you create 4 input text fields and a submit button in a new Flash file. Give the 4 input text fields the following instance names respectively: first_txt, last_txt, email_txt, message_txt. And the submit button: submit_btn.

    Next, type this code in your first frame actions:

    Code:
    submit_btn.onRelease = function(){
    	
    	firstName = first_txt.text;
    	lastName = last_txt.text;
    	email = email_txt.text;
    	message = message_txt.text;
    	
    	loadVariables("http://www.yourwebsite.com/sendMail.php", this, "POST");
    	
    }
    This will store the data in the 4 text fields, into 4 different variables, and then execute the function loadVariables which will open up the sendMail.php on your server/website (which we will create in a second), sending those 4 variables with it to the PHP file.

    Next, open up a text editor and type this PHP code in it:

    PHP Code:
    <?php

    $firstName 
    $_POST['firstName'];
    $lastName $_POST['lastName'];
    $email $_POST['email'];
    $message $_POST['message'];

    $to "your_email@website.com";
    $subject "Guestbook Entry";

    $mailMessage =    "From: " $firstName " " $lastName "\r\n" .
            
    "Email: " $email "\r\n" .
            
    $message;

    mail($to$subject$mailMessage);

    ?>
    This PHP will code will fetch the 4 variables sent from our Flash file, and store them in four different variables ($firstName, $lastName, $email, $message) (variables in PHP must be preceded with a dollar sign) -- then, we create 2 new variables and store the email to which the guestbook entries should be sent to (aka. to YOUR email address) -- and the $subject variable stores the subject of your email (I've chosen Guestbook Entry, to make it easier for you to identify). The last variable, $mailMessage, creates the actual message of your mail, in which we first type the first and last name of the person who wrote the message, then the email, and lastly we print out the message itself written by the user (to join strings, we use a dot . in PHP, not a plus sign + like in Flash). Lastly, we use the PHP function mail() to send our actual mail to your email address.

    Save the PHP file as sendMail.php and upload it to your website.

    You can DOWNLOAD THE FLA FILE HERE

    I know this is not as detailed as you probably expected, but I've kinda written a lot of these PHP tutorials, so I thought I'd drop THIS LINK HERE where I've written a detailed PHP tutorial for a bit different situation, but perhaps it will help you understand PHP better (the new FlashKit layout makes it hard to read my ActionScript code in that tutorial -- so if you see single-line codes with arrows on the side, then it's most likely a long code that you have to read through that one-line display...)

    NOTE: The PHP function mail() is a basic function used to send a simple message, but it's subject to massive spam mail sending, which is why it won't get past the spam filters on most mail clients (like Hotmail, GMail, Yahoo, etc.), and it will most likely be filtered as SPAM mail and sent to your Junk Folder. So, when testing this, make sure you check your junk folder -- I know it'll be a pain in the behind to keep checking the junk folder for new guestbook entries, but I can't help you any further than that as I don't know anymore than this, lol, sorry A better solution would be to have the guestbook entries be posted to a HTML file, where you can view them manually.

    Hope this helps
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Junior Member
    Join Date
    Oct 2008
    Posts
    16
    Quote Originally Posted by Nig 13 View Post
    Hi,

    If you create 4 input text fields and a submit button in a new Flash file. Give the 4 input text fields the following instance names respectively: first_txt, last_txt, email_txt, message_txt. And the submit button: submit_btn.

    Next, type this code in your first frame actions:

    Code:
    submit_btn.onRelease = function(){
    	
    	firstName = first_txt.text;
    	lastName = last_txt.text;
    	email = email_txt.text;
    	message = message_txt.text;
    	
    	loadVariables("http://www.yourwebsite.com/sendMail.php", this, "POST");
    	
    }
    This will store the data in the 4 text fields, into 4 different variables, and then execute the function loadVariables which will open up the sendMail.php on your server/website (which we will create in a second), sending those 4 variables with it to the PHP file.

    Next, open up a text editor and type this PHP code in it:

    PHP Code:
    <?php

    $firstName 
    $_POST['firstName'];
    $lastName $_POST['lastName'];
    $email $_POST['email'];
    $message $_POST['message'];

    $to "your_email@website.com";
    $subject "Guestbook Entry";

    $mailMessage =    "From: " $firstName " " $lastName "\r\n" .
            
    "Email: " $email "\r\n" .
            
    $message;

    mail($to$subject$mailMessage);

    ?>
    This PHP will code will fetch the 4 variables sent from our Flash file, and store them in four different variables ($firstName, $lastName, $email, $message) (variables in PHP must be preceded with a dollar sign) -- then, we create 2 new variables and store the email to which the guestbook entries should be sent to (aka. to YOUR email address) -- and the $subject variable stores the subject of your email (I've chosen Guestbook Entry, to make it easier for you to identify). The last variable, $mailMessage, creates the actual message of your mail, in which we first type the first and last name of the person who wrote the message, then the email, and lastly we print out the message itself written by the user (to join strings, we use a dot . in PHP, not a plus sign + like in Flash). Lastly, we use the PHP function mail() to send our actual mail to your email address.

    Save the PHP file as sendMail.php and upload it to your website.

    You can DOWNLOAD THE FLA FILE HERE

    I know this is not as detailed as you probably expected, but I've kinda written a lot of these PHP tutorials, so I thought I'd drop THIS LINK HERE where I've written a detailed PHP tutorial for a bit different situation, but perhaps it will help you understand PHP better (the new FlashKit layout makes it hard to read my ActionScript code in that tutorial -- so if you see single-line codes with arrows on the side, then it's most likely a long code that you have to read through that one-line display...)

    NOTE: The PHP function mail() is a basic function used to send a simple message, but it's subject to massive spam mail sending, which is why it won't get past the spam filters on most mail clients (like Hotmail, GMail, Yahoo, etc.), and it will most likely be filtered as SPAM mail and sent to your Junk Folder. So, when testing this, make sure you check your junk folder -- I know it'll be a pain in the behind to keep checking the junk folder for new guestbook entries, but I can't help you any further than that as I don't know anymore than this, lol, sorry A better solution would be to have the guestbook entries be posted to a HTML file, where you can view them manually.

    Hope this helps
    Thankyou so much for the help but I will definitely try this and update you...

Tags for this Thread

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