Skip to main content

AS3 to PHP - mail() function



When I click on send the textbox displays 'sending....' with no change. I'm very sure that this was working before, but the client has noticed it not working recently. I can't find the problem, please help.





I have a swf with this AS3







var var_load:URLLoader = new URLLoader;

var URL_request:URLRequest = new URLRequest( "http://www.blah.com/send_email_auto_response.php" );

URL_request.method = URLRequestMethod.POST;



function submit(e:MouseEvent):void

{

if( contact_name.text == "" || contact_email.text == "" ||

contact_subject.text == "" || contact_message.text == "" )

{

message_status.text = "Please fill up all text fields.";

}

else if( !validate_email(contact_email.text) )

{

message_status.text = "Please enter the valid email address.";

}

else

{

message_status.text = "sending...";

var email_data:String = "name=" + contact_name.text

+ "&email=" + contact_email.text

+ "&subject=" + contact_subject.text

+ "&message=" + contact_message.text;



var URL_vars:URLVariables = new URLVariables(email_data);

URL_vars.dataFormat = URLLoaderDataFormat.TEXT;



URL_request.data = URL_vars;

var_load.load( URL_request );

var_load.addEventListener(Event.COMPLETE, receive_response );

}

}







that calls a page with this PHP code..







$contact_name = $_POST['name'];

$contact_email = $_POST['email'];

$contact_subject = $_POST['subject'];

$contact_message = $_POST['message'];

if( $contact_name == true )

{

$sender = $contact_email;

$receiver = "info@blah.com";

$client_ip = $_SERVER['REMOTE_ADDR'];



$email_body = "Name: $contact_name \nEmail: $sender \n\nSubject: $contact_subject \n\nMessage: \n\n$contact_message \n\nIP: $client_ip \n\n";

$email_body_auto_reply = "Hello $contact_name, \nThis is the auto reply message. Thank you.";



$extra = "From: $sender\r\n" . "Reply-To: $sender \r\n" . "X-Mailer: PHP/" . phpversion();

$extra_auto_reply = "From: $receiver\r\n" . "Reply-To: $receiver \r\n" . "X-Mailer: PHP/" . phpversion();



mail( $sender, "Auto Reply - Re: $contact_subject", $email_body_auto_reply, $extra_auto_reply ); // auto reply mail to sender



if( mail( $receiver, "Flash Contact Form - $contact_subject", $email_body, $extra ) )

{

echo "success=yes";

}

else

{

echo "success=no";

}

}




Comments

  1. It could possibly need:

    URL_vars.dataFormat = URLLoaderDataFormat.TEXT;


    changing to:

    URL_vars.dataFormat = URLLoaderDataFormat.VARIABLES;

    ReplyDelete

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.