Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Help With a Flash Contact Form

  1. #1
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help With a Flash Contact Form

    I have a form now that when submitted it uses the getURL function to post to a php page and then loads a blank confirmation page. I would like to use my existing form and submit button to somehow submit the form via a php script but then load an internal flash page (I think maybe using LoadVars and sendAndLoad).

    Here is the existing code:
    SEND BUTTON AS
    Code:
    on (release) {
    	for (i=1; i<_parent.fields_descriptions.length; i++) {
    		if (_parent[_parent.fields_descriptions[i][1]]!=_parent.fields_descriptions[i][2]) {
    			this[_parent.fields_descriptions[i][1]]=_parent[_parent.fields_descriptions[i][1]]+"&777&"+_parent.fields_descriptions[i][2];
    		}
    		_parent.reset_txt(_parent["t"+i], _parent.fields_descriptions[i][1], _parent.fields_descriptions[i][2]);
    	}
    
    	this.recipient=_parent.rec;
    	i=undefined;
    	getURL("contact."+_parent.serv, "_blank", "POST");
    	
    }
    FRAME AS
    Code:
    rec="email@address.com";
    serv="php";
    
    var fields_descriptions= Array ("", 
    									Array("t1", "your_name", "Your Name:"), 
    									Array("t2", "your_email", "Your Email:"),
    									Array("t3", "telephone", "Your Phone:"),
    									Array("t4", "message", "Your Message:"),
    								);
    
    function reset_txt(name,name2,value) {
    		path=eval(_target);
    		path[name2]=value;
    	
    	this[name].onSetFocus=function() {
    		path=eval(_target);
    		if(path[name2]==value) { path[name2]="";} 
    	}
    	
    	this[name].onKillFocus=function() {
    		path=eval(_target);
    		if(path[name2]=="") { path[name2]=value;} 
    	}
    }
    
    
    for (i=1; i<=fields_descriptions.length; i++) {
    	reset_txt("t"+i, fields_descriptions[i][1], fields_descriptions[i][2]);
    }
    PHP CODE
    Code:
    [/C<?php
    Error_Reporting(E_ALL & ~E_NOTICE);
    
     while ($request = current($_REQUEST)) {
     	if (key($_REQUEST)!='recipient') {
    		$pre_array=split ("&777&",  $request);
    		
    		$post_vars[key($_REQUEST)][0]=preg_replace ("/<[^>]*>/", "", $pre_array[0]);
    		$post_vars[key($_REQUEST)][1]=preg_replace ("/<[^>]*>/", "", $pre_array[1]);
    	}
    	next($_REQUEST);
    }
    
    
    
    reset($post_vars);
    
    
    $subject="From ".$post_vars['your_name'][0] ;
    $headers= "From: ".$post_vars['your_email'][0] ."\n";
     $headers.='Content-type: text/html; charset=iso-8859-1';
     $message='';
      while ($mess = current($post_vars)) {
      	if ((key($post_vars)!="i") && (key($post_vars)!="your_email") && (key($post_vars)!="your_name")) {
    
    	 	$message.="<strong>".$mess[1]."</strong>&nbsp;&nbsp;&nbsp;".$mess[0]."<br>";
    	}
    	next($post_vars);
     }
    
    mail($_REQUEST['recipient'], $subject,  "
    <html>
    <head>
     <title>Thank You</title>
    </head>
    <body>
    <br>
      ".$message."
    </body>
    </html>" , $headers);
    ?>
    <html>
    <head>
    <title></title>
    </head>
    //HTML CODE
    </html>

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

    Default

    Take a look at this tutorial: http://www.mediafire.com/?4xe9x1lgsmc*

    It'll walk you through it step by step.

    Post back with any questions

    *Tutorial by Lee Brimelow - gotoAndLearn()

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

    Default

    I am having trouble getting this to work without using Components. I am using just Input text area. Should I be using the instance names or the variable names to reference the variables I am using in the php and AS?

    But even if I use components and have the EXACT same code as the tutorial my form will not e-mail? It runs the receiveLoad function and always shows message failed?

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

    Default

    Do you mind uploading your files?

    Did you upload the PHP file to a server before you tested it? It won't just run locally, you need a server with email support to run the PHP script for it to work.

    The fact that the input fields you use are components vs. not doesn't really matter. It just depends on the instance names.

    I'm not sure what you mean by which name you should be referencing. Your variable names should be equivalent in both PHP and AS. The instance names come into play when you're inputting/outputting something from Flash. So, you don't need any reference to the instance names within PHP.

    In any case, please upload your files (Flash 8 compatible please ) and I'll have a look.

  5. #5
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I sent you a PM with the link to the files...

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

    Default

    Ok, I'll have a look

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

    Default

    Hey Mark...

    Sorry for the late response. I've been busy lately.

    I just had a look at your files.

    I hate dealing with PHP contact forms with flash. They always give me problems. I guess because they're so server dependent. Some things work on some servers, and some don't.

    Try this:

    Where you have
    Code:
    	senderLoad.sendAndLoad("http://yoursite.com/contact.php",receiveLoad);
    replace with:

    Code:
    	senderLoad.sendAndLoad("http://yoursite.com/contact.php",receiveLoad, POST);
    Then in your PHP file,
    make the variables $_POST variables

    Code:
    $message="Name: ".$_POST['t1'];
    $message="\nPhone: ". $_POST['t2'];
    HTH

  8. #8
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Still not working

  9. #9
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    So scratch that...

    The e-mail is now being sent by the server but the receiveLoad function always returns as message failed no matter what.

    Also in the e-mail the only input field that is being sent and published is the Subject and From: Email address. In the actual body of the email the only thing showing up is the Message: field?

    PHP:
    Code:
    <?PHP
    
    $to="info@emailaddress.com";
    $subject="Flash Contact Form Submission";
    $message="Name: ".$_POST['t1'];
    $message="\nPhone: ". $_POST['t2'];
    $message="\nEmail: ". $_POST['t3'];
    $message="\nMessage: ". $_POST['t4'];
    $headers="From: $t3";
    $headers.="\nReply-To: $t3";
    
    $sentOk=mail($to,$subject,$message,$headers);
    echo "sentOK=" . $sentOK;
    
    ?>
    FLASH AS:
    Code:
    stop();
    
    var fields_descriptions= Array ("", 
    									Array("t1", "theName", "Your Name:"), 
    									Array("t2", "thePhone", "Your Phone:"),
    									Array("t3", "theEmail", "Your Email:"),
    									Array("t4", "theMessage", "Your Message:")
    								);
    function reset_txt(name,name2,value) {
    		path=eval(_target);
    		path[name2]=value;
    	
    	this[name].onSetFocus=function() {
    		path=eval(_target);
    		if(path[name2]==value) { path[name2]="";} 
    	}
    	
    	this[name].onKillFocus=function() {
    		path=eval(_target);
    		if(path[name2]=="") { path[name2]=value;} 
    	}
    }
    
    for (i=1; i<=fields_descriptions.length; i++) {
    	reset_txt("t"+i, fields_descriptions[i][1], fields_descriptions[i][2]);
    }
    
    var senderLoad:LoadVars = new LoadVars();
    var receiveLoad:LoadVars = new LoadVars();
    
    clearform.onRelease = function () {
    	t1.text = "";
    	t2.text = "";
    	t3.text = "";
    	t4.text = "";
    	sender.enabled = true;
    }
    
    sender.onRelease = function () {
    	senderLoad.t1 = t1.text;
    	senderLoad.t2 = t2.text;
    	senderLoad.t3 = t3.text;
    	senderLoad.t4 = t4.text;
    	senderLoad.sendAndLoad("http://website.com/contact.php",receiveLoad, POST);
    }
    
    receiveLoad.onLoad = function() {
    	if(this.sentOK) {
    		gotoAndStop("success");
    	}
    	else {
    		gotoAndStop("failed");
    	}
    }

  10. #10
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    You have double quotes in your PHP...

    $message="Name: ".$_POST['t1'];
    "Name: " is the end of the string... you should be using single quotes to connect the strings.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

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
  •