Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
March 19, 2010, 02:58:26 PM

Pages: [1]   Go Down
  Print  
Author Topic: Flash form's "submit" button not working - does nothing  (Read 1174 times)
pb1856
Pong! (the videogame) Master
*****
Offline Offline

Posts: 27


WWW
« on: November 20, 2008, 06:28:11 AM »

Hi everyone, kind of new to flash, so apologize if this is a basic issue - but then atleast easy way to grab some points Wink

So I am setting up a new website using a flash template I downloaded and so far able to figure out everything for the most part.  The only issue now is that the submit button for the form is not working.  When pressed, you see it being pressed, but does nothing to invoke sending the form.  The template had a mailto function setup, so I modified the email address, etc in there and that did not work. 


So then researching, I found information in using PHP.  So I enabled PHP on my web hosting end, created a php script (copied from one of the message boards), and modified the action in flash template to call this php file. Well, atleast I think I did that.

The site is uploaded at www.innovativenetworks.biz

Here is a copy of the PHP script:
~~~~~~~

 
<? 
 
 
 
// Enter your email address here
$adminaddress = "xxxx@innovativenetworks.biz";
 
// Enter the address of your website here MUST include http://www.
$siteaddress ="http://www.innovativenetworks.biz";
 
// Enter your company name or site name here
$sitename = "Innovative Networks";
 
// Gets the date and time from your server
$date = date("m/d/Y H:i:s");
 
// Gets the IP Address
if ($REMOTE_ADDR == "") $ip = "no ip";
else $ip = getHostByAddr($REMOTE_ADDR);
 
//Process the form data!
// and send the information collected in the Flash form to Your nominated email address
IF ($action != ""):
mail("$adminaddress","Visitor Comment from YOUR SITE",
Hello there. You have an email from a visitor who filled out the contact form on your website. Please read below:\n\n
 
 
First Name: $name
Company: $company
Email: $vemail
Phone: $phone
The visitor commented:
------------------------------
$comments
------------------------------
 
Logged Info :
------------------------------
Using: $HTTP_USER_AGENT
Hostname: $ip
IP address: $REMOTE_ADDR
Date/Time:  $date","FROM:$adminaddress");
 
 
//This sends a confirmation to your visitor
mail("$vemail","Thank You for visiting $sitename", "Hi $name,\n
Thank you for your message to $sitename! We will respond based on your provided information shortly.\n
Best Regards,
$sitename
$siteaddress","FROM:$adminaddress");
 
//Confirmation is sent back to the Flash form that the process is complete
$sendresult = "Your message has been sucessfully sent!";
$send_answer = "answer=";
$send_answer .= rawurlencode($sendresult);
echo "$send_answer";
 
ENDIF;
?>


Logged
megB
Newbie
*
Offline Offline

Posts: 2


WWW
« Reply #1 on: December 29, 2008, 03:32:54 PM »

Just wondering if you ever found out the secret to the AS3 submit button on a contact form, especially for LunarPages. Anyone who has asked about this problem receives 0 replies.

I am having the same problem and can't figure it out. I tried to send a contact message to you on your website. But don't think it went through.
Logged
Levi
Pong! (the videogame) Master
*****
Offline Offline

Posts: 26


WWW
« Reply #2 on: December 29, 2008, 06:38:19 PM »

What flash code did you modify to call the file, what did you modify?
Logged
megB
Newbie
*
Offline Offline

Posts: 2


WWW
« Reply #3 on: December 30, 2008, 03:21:37 PM »

I basically have a flash portfolio web site. The only thing that doesn't work is the submit button on my contact page. I can receive email at contact@megbisharat.com and am able to send from the same. This is a stupid scripting error in Flash that I can't figure out. (probably this line: var URL_request:URLRequest = new URLRequest("http://contact@megbisharat.com");

This is my AS3 code for the contact page:

import flash.net.URLRequest;
stop ();

contact_name.text = contact_email.text = contact_subject.text =
contact_message.text = message_status.text = "";

send_button.addEventListener (MouseEvent.CLICK, submit);
reset_button.addEventListener (MouseEvent.CLICK, reset);

var timer:Timer;
var var_load:URLLoader = new URLLoader;
var URL_request:URLRequest = new URLRequest("http://contact@megbisharat.com");
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 );
   }
}

function reset (e:MouseEvent):void
{
   contact_name.text = contact_email.text = contact_subject.text =
   contact_message.text = message_status.text = "";
}

function validate_email (s:String):Boolean
{
   var p:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;
   var r:Object = p.exec(s);
   if ( r == null )
   {
      return false;
   }
   return true;
}

function receive_response (e:Event):void
{
   var loader:URLLoader = URLLoader(e.target);
   var email_status = new URLVariables(loader.data).success;

   if ( email_status == "yes" )
   {
      message_status.text = "Success! Your message was sent.";
      timer = new Timer(500);
      timer.addEventListener (TimerEvent.TIMER, on_timer);
      timer.start ();
   } else
   {
      message_status.text = "Failed! Your message can not be sent.";
   }
}

function on_timer (te:TimerEvent):void
{
   if ( timer.currentCount >= 10 )
   {
      contact_name.text = contact_email.text = contact_subject.text =
      contact_message.text = message_status.text = "";
      timer.removeEventListener (TimerEvent.TIMER, on_timer);
   }
}

I am definitely not an expert and am in learning mode. Thanks, in advance.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to: