flash cs3 and php problem (system error)
Copy link to clipboard
Copied
Hi All,
Been checking out a free utility, called Tell A Friend - followed the instructions to a t but still getting system error.
Here is the php code:
<?php
$to = ($_POST['friend']);
$link = ($_POST['link']);
$subject = "Tell a friend";
$message = "Your friend ";
$message .= $_POST['name'] . " wants advice you the following link: ".$link;
$headers = "My WebSite Name";
if(@mail($to, $subject, $message, $headers))
{
echo "answer=ok";
}
else
{
echo "answer=error";
}
?>
The main swf has a main.as attached:
/*
*************************************
* Flash Tell A Friend
* http://www.FlepStudio.org
* Author: Filippo Lughi
* version 1.0
*************************************
*/
package
{
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.external.*;
import flash.net.*;
public class main extends MovieClip
{
private const PHP_URL:String="sendMail.php";
private var checker:CheckEmail;
private var timer:Timer;
public function main()
{
addEventListener(Event.ADDED_TO_STAGE,init);
}
private function init(evt:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE,init);
stage.frameRate=31;
checker= new CheckEmail();
addInputListener();
addSendListener();
}
private function addInputListener():void
{
clip_mc.name_txt.background=true;
clip_mc.name_txt.backgroundColor=0x999999;
clip_mc.name_txt.addEventListener(FocusEvent.FOCUS_IN,onFocusIn);
clip_mc.name_txt.addEventListener(FocusEvent.FOCUS_OUT,onFocusOut);
clip_mc.email_txt.background=true;
clip_mc.email_txt.backgroundColor=0x999999;
clip_mc.email_txt.addEventListener(FocusEvent.FOCUS_IN,onFocusIn);
clip_mc.email_txt.addEventListener(FocusEvent.FOCUS_OUT,onFocusOut);
}
private function onFocusIn(evt:Event):void
{
evt.target.background=true;
evt.target.backgroundColor=0xFFFFFF;
}
private function onFocusOut(evt:Event):void
{
evt.target.backgroundColor=0x999999;
}
private function addSendListener():void
{
clip_mc.send_mc.mouseChildren=false;
clip_mc.send_mc.buttonMode=true;
clip_mc.send_mc.addEventListener(MouseEvent.MOUSE_DOWN,onSendDown);
}
private function onSendDown(evt:MouseEvent):void
{
if(clip_mc.name_txt.text!="")
{
if(checker.initCheck(clip_mc.email_txt.text))
sendEmail();
else
displayPhrase("Invalid Email");
}
else
displayPhrase("Invalid name");
}
private function sendEmail():void
{
clip_mc.send_mc.mouseEnabled=false;
var variables:URLVariables=new URLVariables();
variables.name=clip_mc.name_txt.text;
variables.friend=clip_mc.email_txt.text;
variables.link=ExternalInterface.call('window.location.href.toString');
var request:URLRequest=new URLRequest();
request.url=PHP_URL;
request.method=URLRequestMethod.POST;
request.data=variables;
var loader:URLLoader=new URLLoader();
loader.dataFormat=URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE,onMessageSent);
try
{
loader.load(request);
}
catch (error:Error)
{
trace('Unable to load the document.');
}
}
private function onMessageSent(evt:Event):void
{
var vars:URLVariables=new URLVariables(evt.target.data);
if(vars.answer=='ok')
displayPhrase("Message Sent!");
else
displayPhrase("System Error!");
clip_mc.send_mc.mouseEnabled=true;
clip_mc.name_txt.text="";
clip_mc.email_txt.text="";
}
private function displayPhrase(s:String):void
{
clip_mc.display_txt.text=s;
resetPhrase();
}
private function resetPhrase():void
{
timer=new Timer(1500,1);
timer.addEventListener(TimerEvent.TIMER,hidePhrase);
timer.start();
}
private function hidePhrase(evt:TimerEvent):void
{
clip_mc.display_txt.text="";
}
}
}
Any help appreciated. This is a great viral marketing tool, when it ever works
Kind Regards,
Boxing Boom
Copy link to clipboard
Copied
Hi there,
Lets start with basic question: What's the error message?
I've checked the code and all I can tell now is that it looks correct. Hard to find any bug (it's probably minor) when you don't know where to look. Is the error in PHP or in Flash? Do you know wheter there is a response from PHP?
And, first question I should ask : Do you have PHP installed? That means, are you testing it on a server with PHP installed or on your local hard drive with a PHP server simulation?
Copy link to clipboard
Copied
Hi,
Thanks for responding; ya I am testing it on a fasthosts server over the internet. Not sure if it's php error or flash; how should I test for this?
Error message is System Error! and within the status bar of the browser window it states Error on page consisting of:
Object doesn't support this properity or method.
code:0
Hope you can see a fix, for this
Heres the url where I got this handy free utility:
http://www.flepstudio.org/forum/flepstudio-utilities/3444-tell-friend.html
Kind Regards,
Boxing Boom
Copy link to clipboard
Copied
Hi,
Just wondering if this problem may be caused by the php permissions, however I have other flash and php email forms that are working fine, with permissions set to 700.
Anyone got any other angles on this, or experienced similiar issues.
Kind Regards,
Boxing Boom
Copy link to clipboard
Copied
Never seen such an error, but if it's in the status bar of the browser then it shouldn't be Flash problem. You can check what's happening in your swf by creating a dynamic text field and setting it's text in every major action, that is: requesting PHP and getting back response, to what's just happened.
So, on the Flash side you can see whether the browser error stops the PHP script and immobilizes further actions.
What I'd do is create a new Flash file and PHP file and just send 1 variable to PHP, change it somehow and send it back to Flash and print it in a text field. That way you can check whether it's the method you're using to request PHP or just PHP or something else. Step by step adding complexity and checking on which of these steps the error occurs.
I wish you good luck.
Ps. It's probably a very rookie problem, we just don't know the source.
Copy link to clipboard
Copied
Hi Muho_tr,
Thanks once again for your welcomed response; Just been in touch with fasthosts my isp providers, and it's down to the following:
ini_set("sendmail_from", " user@yourdomain.com ");
A very nice guy there, is now ammending this for me
It's a fasthosts requirment.
Kind Regard's,
Boxing Boom
Copy link to clipboard
Copied
Hehe, uff wasn't my lack of knowledge.

