Results 1 to 3 of 3

Thread: Submit button?

  1. #1
    Join Date
    Oct 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Talking Submit button?

    Howdy Y'all

    Am not really new to flash but still have a long way to go yet and a lot to learn it seams. I got me a template and I am building a new website www.whisperedmyth.com/expo to replace my old one and have just about finished except for the contact form.

    I have managed to figure out how all the other stuff is done except for the submit button on the contact page. If you go to the site and to the contact page you will see a few fields you fill out and then hit submit. I don't want this to be a mailto setup like the old site.

    Can someone explain or point me in a direction to learn what this button needs to have for action script?

    Thank Ya!!!

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    I suggest using some simple PHP.

    The easiest way to takcle this is using loadVars. loadVars is specifficaly made for this kind of application - sending to server side scripts.

    From your website, it looks like you have everything already bulit.

    Here is what you would do to send back/forth to the PHP:

    1) For the actionscript below to work, change your instance names to:

    Code:
    theName // name input field
    theEmail // email input field
    theMessage // message txt area
    sender // submit button
    2) Add the following actionscript to the controlling frame.

    Code:
    stop();
    
    var senderLoad:LoadVars = new LoadVars(); // loadVars variable to send data
    var recieveLoad:LoadVars = new LoadVars();  // loadVars variable to recieve data
    
    sender.onRelease = function() {  // when you hit the send button
    	senderLoad.theName = theName.text;  // creates variable for the name field
    	senderLoad.theEmail = theEmail.text;  // this is for the email field
    	senderLoad.theMessage = theMessage.text; //  and the message
    	senderLoad.sendAndLoad("http://www.domain.com/send.php",recieveLoad);  // change the URL to your php script
    }
    
    receiveLoad.onLoad = function() {  //  data that comes back from the PHP
    	if(this.sentOk) {  // if the message was successful
    		theMessage.text = "Success"
    	}
    	else { // if the message did not send
    		theMessage.text = "Failure"
    	}
    }

    And here is the simple PHP script.

    PHP Code:
    <?PHP

    $to 
    "youremail@domain.com";  // add your email address
    $subject "Website Contact Form";
    $message "Name: " $theName;
    $message .= "\nEmail: " $theEmail;
    $message .= "\n\nMessage: " $theMessage;
    $headers "From: $theEmail";
    $headers .= "\nReply-To: $theEmail";

    $sentOk mail($to,$subject,$message,$headers);

    echo 
    "sentOk=" $sentOk;  // sends back a boolean value based on the success of the script

    ?>

  3. #3
    Join Date
    Oct 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank You Medyman!!

    I have been working a little here and there on my new site in my spare time. I am also remodling my house and restoring a 1959 ford truck so spare time is pretty minimal now days.

    I will copy this down and see about making the buttons do something beside sit and look pretty. ;-)

Bookmarks

Posting Permissions

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