A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: Code Check Please...

  1. #1
    Senior Member
    Join Date
    Jul 2001
    Location
    Tinley Park, IL
    Posts
    702

    Code Check Please...

    It's for a eMail form. It used to work but for some reason, it's not working now...Let me rephrase, it does still send the eMail but it's not getting a returning variable, so it will go to the "Thank You" page.

    I've looked over the code for hours and can't seem to get it to return the variable...What's weird is that I used this code for the contact form on http://www.nssclan.org and that one suddenly doesn't work either....It did the other day.

    Could someone look over the code and see if there is something wrong with it? I wrote this code with Chris' help in when version 4 was out.

    Here is the code in the frame of the form.

    Code:
    // Check for blank fields and submit 
    sendbutton.onRelease = function(){
    	if(fullname.text == ""||email.text==""||agree.text==""||lastname.text==""||dob.text==""||gbname.text==""||eseal.text==""){
    		// If any of the fields are blank
    		errormessage._x = 150;
    		errormessage.gotoAndPlay("go");
    		
    		}else{
    			var result_lv = new LoadVars();
    			result_lv.onLoad = function(success){
    				if(success){
    					fullname.text="";
    					lastname.text="";
    					email.text="";
    					dob.text="";
    					gbname.text="";
    					eseal.text="";
    					agree.text="";
    					myresponse.text = result_lv.returnMe;
    					gotoAndPlay("thanks");
    						
    				}else{
    				myresponse.text = "error"
    				unknown_error._x = 150;
    				unknown_error.gotoAndPlay("go");
    				}
    			}	
    		}
    // Send the Data	
    var send_lv = new LoadVars();
    	send_lv.action = "send";
        send_lv.fullname = fullname.text;
    	send_lv.lastname = lastname.text;
    	send_lv.email = email.text;
    	send_lv.dob = dob.text;
    	send_lv.gbname = gbname.text;
    	send_lv.eseal = eseal.text;
    	send_lv.agree = agree.text;
    	send_lv.subject = subject.text;
    	send_lv.recipient = recipient.text;
       	send_lv.sendAndLoad("clanrequest.php",result_lv,"POST");
     };
    Here is the php code for reading the submission data, sending the email and sending reply back to my movie.
    clanrequest.php
    PHP Code:
    <? 

    $fullname = $_POST["fullname"];
    $lastname = $_POST["lastname"];
    $email_addy = $_POST["email"];
    $dob = $_POST["dob"];
    $gbname = $_POST["gbname"];
    $eseal = $_POST["eseal"];
    $agree = $_POST["agree"];
    $subject = $_POST["subject"];
    $recipient = $_POST["recipient"];
    $action = $_POST["action"];


    // Log the IP address of sender
    $ip = $_SERVER['REMOTE_ADDR']; 
    $date = date("m/d/Y H:i:s"); // Date the form was sent

     

    if ($action == "send") { 
        mail ("$recipient","$subject", 
        "A visitor has requested to join your clan:\n 
        
        From:   $lastname, $fullname
        eMail:  $email_addy
            GB Name: $gbname
            eSeal name: $eseal
            DOB: $dob
            
            $agree, I agree to the clan rules and code of conduct.
                
        
        
        Logged Info : 
        ------------------------------ 
        Using: $HTTP_USER_AGENT 
        IP address: $ip 
        Date/Time:  $date", "FROM:$email_addy") ; 
          
          }
          echo "&returnMe=thanks";
         
    ?>
    My Sites: Gaming Site Nightshade Studios MyKM Tutorials

    --------------------------------------------------
    What I'm using: Gimp, Koolmoves, Sepy, HTML-Kit, Inkscape

  2. #2
    That web bloke Stoke Laurie's Avatar
    Join Date
    Jan 2006
    Location
    England
    Posts
    869
    <?
    ini_set("sendmail_from", " [email protected] "); //configure this to you
    //LoadVar_Mailform for Koolmoves © 2006 Chris Seahorn (http://sandbox.blogdns.com//[email protected])
    $fullname = $_POST["fullname"];
    $lastname = $_POST["lastname"];
    $email_addy = $_POST["email"];
    $dob = $_POST["dob"];
    $gbname = $_POST["gbname"];
    $eseal = $_POST["eseal"];
    $agree = $_POST["agree"];
    $subject = $_POST["subject"];
    $recipient = $_POST["recipient"];
    $action = $_POST["action"];


    $ip = $_SERVER['REMOTE_ADDR'];

    $adminaddress = "[email protected]"; //configure this to you
    $siteaddress ="your web address"; //configure this to you
    $sitename = "Your Site Name"; //configure this to you

    $date = date("m/d/Y H:i:s");

    $action = $_POST["action"];


    if ($action == "send") {
    mail ("$adminaddress","A visitor has requested to join your clan\n",

    From: $lastname, $fullname
    eMail: $email_addy
    GB Name: $gbname
    eSeal name: $eseal
    DOB: $dob

    $agree, I agree to the clan rules and code of conduct.


    Logged Info :
    ------------------------------
    Using: $HTTP_USER_AGENT
    IP address: $ip
    Date/Time: $date","FROM:$adminaddress" ) ;



    //Confirmation is sent back to the Flash form that the process is complete

    echo "&returnMe=thanks";



    }


    ?>

  3. #3
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Looked to me like you should define result_lv here

    var send_lv = new LoadVars();
    var result_lv=new LoadVars();
    send_lv.action = "send";
    send_lv.fullname = fullname.text;
    send_lv.lastname = lastname.text;
    send_lv.email = email.text;
    send_lv.dob = dob.text;
    send_lv.gbname = gbname.text;
    send_lv.eseal = eseal.text;
    send_lv.agree = agree.text;
    send_lv.subject = subject.text;
    send_lv.recipient = recipient.text;
    send_lv.sendAndLoad("clanrequest.php",result_lv,"P OST");
    };

  4. #4
    Senior Member
    Join Date
    Jul 2001
    Location
    Tinley Park, IL
    Posts
    702
    Quote Originally Posted by blanius
    Looked to me like you should define result_lv here

    var send_lv = new LoadVars();
    var result_lv=new LoadVars();
    send_lv.action = "send";
    send_lv.fullname = fullname.text;
    send_lv.lastname = lastname.text;
    send_lv.email = email.text;
    send_lv.dob = dob.text;
    send_lv.gbname = gbname.text;
    send_lv.eseal = eseal.text;
    send_lv.agree = agree.text;
    send_lv.subject = subject.text;
    send_lv.recipient = recipient.text;
    send_lv.sendAndLoad("clanrequest.php",result_lv,"P OST");
    };
    NO, that change caused the form to not even send the data. Probably because I already called this function in the IF statement.
    Last edited by dniezby; 12-17-2006 at 04:32 PM.
    My Sites: Gaming Site Nightshade Studios MyKM Tutorials

    --------------------------------------------------
    What I'm using: Gimp, Koolmoves, Sepy, HTML-Kit, Inkscape

  5. #5
    That web bloke Stoke Laurie's Avatar
    Join Date
    Jan 2006
    Location
    England
    Posts
    869
    Go back to Koolexchange and download Chris's loadvars again.
    Change the field names to what you need and the code to match, If I can suggest that you stick to Chris's convention of calling the fields box1 and box2 etc, you will find it easy to trace them through your actionscript and then the php.
    I just added this line
    ini_set("sendmail_from", " [email protected] "); because some servers require this as authority to POST.

  6. #6
    Senior Member
    Join Date
    Jul 2001
    Location
    Tinley Park, IL
    Posts
    702
    Quote Originally Posted by Stoke Laurie
    Go back to Koolexchange and download Chris's loadvars again.
    Change the field names to what you need and the code to match, If I can suggest that you stick to Chris's convention of calling the fields box1 and box2 etc, you will find it easy to trace them through your actionscript and then the php.
    I just added this line
    ini_set("sendmail_from", " [email protected] "); because some servers require this as authority to POST.
    I put this in the PHP, but that didn't work either.

    You know what pisses me off? It USED to work. I didn't change anything except add fields. I've looked over Chris' code and it's the same.

    I just wish I knew "where" the error was. I think it's in the PHP echoing back...
    Any thoughts on how I can test to see if it really is echoing out?
    My Sites: Gaming Site Nightshade Studios MyKM Tutorials

    --------------------------------------------------
    What I'm using: Gimp, Koolmoves, Sepy, HTML-Kit, Inkscape

  7. #7
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    call the PHP file directly in the browser. Also I'm willing to bet it's in the actionscript and has to do with differences in flash 8, which would explain why it stopped working as that probably is something that DID change.

  8. #8
    Senior Member
    Join Date
    Jul 2001
    Location
    Tinley Park, IL
    Posts
    702
    You're right, the PHP returns correctly...

    Hmm, then I wonder what the heck I can do now.

    The whole issue isn't the actual sending of the form. That works fine. I was using the return value to wait for confirmation from the PHP then move on to the thankyou page.

    Any thoughts?
    My Sites: Gaming Site Nightshade Studios MyKM Tutorials

    --------------------------------------------------
    What I'm using: Gimp, Koolmoves, Sepy, HTML-Kit, Inkscape

  9. #9
    That web bloke Stoke Laurie's Avatar
    Join Date
    Jan 2006
    Location
    England
    Posts
    869
    Why don't you try Chris's as a control by loading his swf and php to your server, assuming the echo is returned you then know you have a version that does what you want, all you then need to do is redress the swf to look the way you want it to, leave the variable the way Chris created them and simply change the text boxes to reflect what you want them to type in.

  10. #10
    Senior Member
    Join Date
    Jul 2001
    Location
    Tinley Park, IL
    Posts
    702
    Well, I figured out the problem.

    It seems that the return variable may have been getting stuck elsewhere in the movie.

    The problem was here:

    Code:
    myresponse.text = result_lv.returnMe;
    gotoAndPlay("thanks");
    And here is the solution:

    Code:
    _root.gotoAndPlay("thanks');
    Something must have changed in Flash 8 to make me have to specify that the returning variable needed to go back to the root.

    You can see the live form at
    http://www.nssclan.orgl Then click the JOIN US button.
    Just put DEMO in for your email address if you're goint to try it. All the cool stuff happens after you send the form.
    NOTE: JUST IN CASE THE FORM DOESN'T OPEN, (I'M TESTING SOME JAVASCRIPT TO OPEN THE FORM IN A NEW WINDOW) You can go directly to the form at http://www.nssclan.org/forms/joinclan.html
    Last edited by dniezby; 12-18-2006 at 05:19 PM.
    My Sites: Gaming Site Nightshade Studios MyKM Tutorials

    --------------------------------------------------
    What I'm using: Gimp, Koolmoves, Sepy, HTML-Kit, Inkscape

  11. #11
    That web bloke Stoke Laurie's Avatar
    Join Date
    Jan 2006
    Location
    England
    Posts
    869
    Excellent glad you found the answer. Tried the form very good.
    If I were you I would check the point size or the size of the text fields that you fill in as the text seemed too big for the box. By the way why not just use a _blank url link from the main swf to the forms page?

  12. #12
    Senior Member
    Join Date
    Jul 2001
    Location
    Tinley Park, IL
    Posts
    702
    Quote Originally Posted by Stoke Laurie
    Excellent glad you found the answer. Tried the form very good.
    If I were you I would check the point size or the size of the text fields that you fill in as the text seemed too big for the box. By the way why not just use a _blank url link from the main swf to the forms page?
    I did that but it just opens a new window and not a specific sized window.
    My Sites: Gaming Site Nightshade Studios MyKM Tutorials

    --------------------------------------------------
    What I'm using: Gimp, Koolmoves, Sepy, HTML-Kit, Inkscape

  13. #13
    Senior Member
    Join Date
    Jul 2001
    Location
    Tinley Park, IL
    Posts
    702
    Quote Originally Posted by Stoke Laurie
    Excellent glad you found the answer. Tried the form very good.
    If I were you I would check the point size or the size of the text fields that you fill in as the text seemed too big for the box. By the way why not just use a _blank url link from the main swf to the forms page?
    Fixed the text boxes and now the form opens correctly. I hope you have a chance to check it out again.
    My Sites: Gaming Site Nightshade Studios MyKM Tutorials

    --------------------------------------------------
    What I'm using: Gimp, Koolmoves, Sepy, HTML-Kit, Inkscape

  14. #14

  15. #15
    Senior Member
    Join Date
    Jul 2001
    Location
    Tinley Park, IL
    Posts
    702
    Check out the Profiles Folder - The data isn't there yet but the graphics and animation are...What do ya think?
    My Sites: Gaming Site Nightshade Studios MyKM Tutorials

    --------------------------------------------------
    What I'm using: Gimp, Koolmoves, Sepy, HTML-Kit, Inkscape

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