Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Remember me

Go Back   Tutorialized Forums2D GraphicsFlash

Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
Unread Tutorialized Forums Sponsor:
Old June 18th, 2011, 01:35 PM
Dylancougar Dylancougar is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
Join Date: Apr 2011
Posts: 2 Dylancougar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 44 m 17 sec
Reputation Power: 0
Odd Php Contact Form Problem

I used a tutorial from this site http://www.developphp.com, that helped me create a contact form, for my site.

It all works fine, sending email, messages etc, except that it seems to be sending the content of the email, the actual body text as an attachment, because when I check my email on the site their is no body text that is displayed, just an attachment. I'm at a lost to figure out why and the forum closed down at the site that I followed the tutorial from.

Is there anything in the AS3 code below, or the php code that indicates why this could be the case. Am I miss something obvious?

AS3 code:

// Set text formatting colors for errors, waiting..., and success mechanisms
var errorsFormat:TextFormat = new TextFormat();
errorsFormat.color = 0xFF0000;

var waitingFormat:TextFormat = new TextFormat();
waitingFormat.color = 0x339900;

var successFormat:TextFormat = new TextFormat();
successFormat.color = 0x3366FF;

// hide the little processing movieclip
processing_mc.visible = false;

// Assign a variable name for our URLVariables object
var variables:URLVariables = new URLVariables();

//  Build the varSend variable
var varSend:URLRequest = new URLRequest("http://www.mountcalvarybaptistchurchspringfield.org/prayer_parse.php");
varSend.method = URLRequestMethod.POST;
varSend.data = variables;

// Build the varLoader variable
var varLoader:URLLoader = new URLLoader;
varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
varLoader.addEventListener(Event.COMPLETE, completeHandler);

// Handler for PHP script completion and return
function completeHandler(event:Event):void{
    // remove processing movieclip
    processing_mc.visible = false;
    // Clear the form fields
    name_txt.text = "";
    email_txt.text = "";
    msg_txt.text = "";
	// Load the response from the PHP file
    status_txt.text = event.target.data.return_msg;

// Add an event listener for the submit button and what function to run
submit_btn.addEventListener(MouseEvent.CLICK, ValidateAndSend);

// Validate form fields and send the variables when submit button is clicked
function ValidateAndSend(event:MouseEvent):void{
    //validate form fields
    if(!name_txt.length) {	
		status_txt.text = "Please enter your name.";	
	} else if(!email_txt.length) {
        status_txt.text = "Please enter an email address";
	} else if(!validateEmail(email_txt.text)) {
		status_txt.text = "Please enter a VALID email address";
	} else if(!msg_txt.length) {
		status_txt.text = "Please enter a message.";
	} else {
		// All is good so send the message to the parse file
		// Show the little "processing_mc" movieclip
        processing_mc.visible = true;
		// Ready the variables for sending
  		variables.userName = name_txt.text;
   		variables.userEmail = email_txt.text;
   		variables.userMsg = msg_txt.text;	

		// Send the data to the php file
		// Put a temporary message in the response field while the PHP file sends back
		// If the code does not connect to the PHP file this message will remain visible to user
		status_txt.text = "Waiting for server connection...";

	} // close else after form validation

} // Close ValidateAndSend function //////////////////////////////////////////////////////////////

// Validate email function
function validateEmail(str:String):Boolean {
	var pattern:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;
	var result:Object = pattern.exec(str);
	if(result == null) {
		return false;
	return true;

PHP script:


             ---     Created by Adam Khoury @ www.developphp.com      ---

// Create local variables from the Flash ActionScript posted variables
$senderName   = $_POST['userName'];
$senderEmail     = $_POST['userEmail'];
$senderMessage = $_POST['userMsg'];

// Strip slashes on the Local variables for security
$senderName   = stripslashes($senderName);
$senderEmail     = stripslashes($senderEmail);
$senderMessage   = stripslashes($senderMessage); 

// IMPORTANT - Change these lines to be appropriate for your needs - IMPORTANT
$to = "prayer@mountcalvarybaptistchurchspringfield.org";			 
$from = "$senderEmail";
$subject = "Prayer Request from the site";
// Modify the Body of the message however you like
$message = "Message from your website:

Their Name:   $senderName 

Their Email:   $senderEmail

Their Message is below: 

// Build $headers Variable
$headers = "From: $from\r\n";
$headers .= "Content-type: text\r\n"; 
$to = "$to";
    // Send the email
    mail($to, $subject, $message, $headers);
	// Assemble the message that goes back to Flash
	// The flash ActionScript is looking for a return variable of "return_msg"
	$my_msg = "Thanks $senderName, your message has been sent.";
	// Print the data back to flash who is patiently waiting for it in the onCompleteHandler
    print "return_msg=$my_msg"; 
// Exit script	

Reply With Quote

Viewing: Tutorialized Forums2D GraphicsFlash > Odd Php Contact Form Problem

Developer Shed Advertisers and Affiliates

Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.

© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap