# Email contact form does'nt work

**URL:** <https://forum.kirupa.com/t/email-contact-form-doesnt-work/315602>\
**Category:** Uncategorized\
**Created:** [October 30, 2010, 1:10am UTC](https://forum.kirupa.com/t/email-contact-form-doesnt-work/315602 "2010-10-30T01:10:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Batterman](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@Batterman](https://forum.kirupa.com/u/Batterman)\
**Post date:** [October 30, 2010, 1:10am UTC](https://forum.kirupa.com/t/email-contact-form-doesnt-work/315602/1 "2010-10-30T01:10:51Z")

</div>

Hi

When testing my email contact form in flash cs5 it works fine and is sending an email but when uploaded to a server it won´t send anything.

i got these files:

**[COLOR=“Red”]email.php[/COLOR]**  
\<?php  
$to = "tr\_di@hotmail.com";  
$subject = "Email fra: " . ($\_POST[‘name’]);  
$message = ($\_POST[‘message’]);  
$message .= "

* * *

";  
$message .= “E-mail: " . $\_POST[‘name’] . " \<” . $\_POST[‘email’] . "\>  
";  
$headers = “From: " . $\_POST[‘name’] . " \<” . $\_POST[‘email’] . "\>  
";  
if(@mail($to, $subject, $message, $headers))  
{  
echo “answer=ok”;  
}  
else  
{  
echo “answer=error”;  
}  
?\>

**[COLOR=“red”]ContactBoxText.as[/COLOR]**  
package{  
import etc.  
//code

```
		sendbutton.addEventListener(MouseEvent.CLICK, sendemail, false,0,true);

		function sendemail(e:MouseEvent):void
		{
			//check fails
			if (inputtext1.text == "")
			{
				errortext.text = "Please Type in your name";
			}
			else if (inputtext2.text == "")
			{
				errortext.text = "Please type in your email adress";
			}
			else if (inputtext3.text == "")
			{
				errortext.text = "Please Type in your message";
			}
			else
			{
				sendMessage();
			}

		}
	}
	private function sendMessage():void
	{
		const SCRIPT_URL:String = "http://www.trungdinh.dk/email.php";
		var request:URLRequest = new URLRequest(SCRIPT_URL);
		var variables:URLVariables = new URLVariables();

		// these depend on what names the script expects
		variables.name = inputtext1.text;
		variables.email = inputtext2.text;
		variables.message = inputtext3.text;

		request.data = variables;

		// depends if the script uses POST or GET
		// adjust accordingly
		request.method = URLRequestMethod.POST;

		var loader:URLLoader=new URLLoader();
		loader.dataFormat = URLLoaderDataFormat.VARIABLES;
		loader.addEventListener(Event.COMPLETE,messageSent);
		try
		{
			loader.load(request);
		}
		catch (error:Error)
		{
			trace('Unable to load requested document.');
		}
	}

	private function messageSent(evt:Event):void
	{
		var loader:URLLoader = URLLoader(evt.target);
		var vars:URLVariables = new URLVariables(loader.data);
		if (vars.answer == "ok")
		{
			trace("The message has been sent");
			errortext.text = "Your message has been send!";
		}
		else
		{
			trace("Something wrong");
			errortext.text = "something is wrong";
		}
	}

}

```

}
