AS3 / PHP email form HELP

phils13776

New Member
Messages
18
Reaction score
0
Points
0
This java form is really not working for me. I there any way to use a non-java form with you php script?

Maybe three are simple edits i need to make (the template I am using is below). Also attached 2 templates that can work.View attachment flash_contact_form.zipView attachment php_flash_email_form_by_MacromediaHelp.zip

SCRIPT :

serverFile = "contact_form.php";

stop();

//function to seperate form validation checks from email sending logic

function formValidationChecks(){

//checking if email format is valid

if ((!email.text.length) || (email.text.indexOf("@") == -1) || (email.text.indexOf(".") == -1)) {
status.text = "Please enter a valid E-mail address";
return false;
//checking if from field is not blank
} else if (!from.text.length) {
status.text = "Please enter Your Name";
return false;
//checking if message is not blank
} else if (!message.text.length) {
status.text = "Please Enter Your Message";
return false;
}
return true;
}
 

bidzey75

New Member
Messages
53
Reaction score
0
Points
0
what do you want to do? make sure no fields are left empty? As far as the email field goes AS3 is taking care of that already so you don't need to check for it again. You can't anyways, all this is predifiened in the AS3 class and once you compile it to a .SWF file you can't access those fields outsite of flash. You can manipulate the post vars but that's because AS3 programmed it that way. Long story short, if you want to make sure all the fields are not left empty, you have to modify the AS3 code. You can't do it externaly. If you temp to catch the ($_POST[] var) at the php level then you screw up the pattern of the initial logic of the flash and nothing gets sent.

Is there a reason why you want to use flash for a simple contact form? HTML, javascript, PHP combo would make your life alot easier. (Unless you know how to code AS3). I see you posted 2 other flash contact forms, are you still using the same one?
 

bidzey75

New Member
Messages
53
Reaction score
0
Points
0
I modified the AS3 class, now if the user leaves name, and message with the default or empty they will be notified and stoped.

back up your "contact_form.swf" DO NOT overwrite it with this one, I only tested it locally, and there were considerable changes made to the AS3 code. KEEP a backup if you want to use this one. rename the old version swf file and simply upload this one.
 

Attachments

  • deploy.zip
    38.1 KB · Views: 22

phils13776

New Member
Messages
18
Reaction score
0
Points
0
I'm mainly concerned with the placement of the form within the flash movie. Since there are no objects (they are rendered by java), and no X= Y= parameters I cant really manipulate the form. (sorry for not being clear previously)

i opened the java file to find the parameters, but the code is such a mess i cant find anything. :(
 
Last edited:

bidzey75

New Member
Messages
53
Reaction score
0
Points
0
Well it's hard for me to view your problem. Sound like your trying to import that movie into another. I never did that before so I couldn't help you with that. The javascript stuff I highly doubt as anything to do with it. If you want to control the placement of the form you'll need to tweek the AS3 again not the javascript. Maybe this will help you I'm not sure, but to place the form at a certain place follow these steps.

If you don't care about the changes I did in the class file you can skip step 2 and 3

You will need Adobe Flash CS4 to do this, I can't do it for you. Worse thing is you might have to download the trial version if you don't have it.

step 1 - make a backup of everything I gave you so far and store it away.

step 2 open the ContactForm.as file (this is the class file) you will find it in this folder of the original package I posted (ActionScript version\src\classes\com\warmforestflash)

step 3 replace all of the code in that file with this: (the changes I did earlier)

I get too long of a post error, so just download the file


step 4 - now open the contact_form.fla in the src folder.
you will see at the bottom a line that says addChild(contactForm);
underneith that line you can manipulate where to add the child (contact form in this case)
you can add
Code:
contactForm.x = xxx; // where xxx is a number on the X axis
contactForm.y = xxx; // where xxx is a number on the Y axis

after you're done, save both files in their respected folders, then in the contact_form.fla go File, Export Movie and save your new swf file replacing the other one you're using.

hopes this helps...

and yes the author uses an advance technique to create this flash. nothing is on stage, everything is created by AS3 on demand.
The difference between AS2 and AS3 is black and white, AS3 is a full blown object orientation language and very powerful.
 

Attachments

  • ContactForm.zip
    3.4 KB · Views: 29
Last edited:

phils13776

New Member
Messages
18
Reaction score
0
Points
0
Bidzey, I finally got it to work. Im just really rusty in flash. Thank you for the parameters i will definitely use those to correct the placement. I will also use the updated php you gave me. You have been a great help.

Here is what i was trying to to do: http://www.lavidapictures.com/

Click the 4th bar from the left. Working contact form YAY. All thanks to you.
 

bidzey75

New Member
Messages
53
Reaction score
0
Points
0
if you notice in the fla file you can also set other parameters, they're all commented out, but nothing stops you from uncommenting them and tweek the size, and other parameters.

some credit also goes to descalzo, I used his idea to find the solution of the mail() function post 16 here

site looks good, i guess you just need to lower the contact form a bit. Or really you seem to have enough space above, why don't you just move the title up a bit (the one that's behind the "name" field) and not even touch the form... if that's what your trying to do.
 
Last edited:

phils13776

New Member
Messages
18
Reaction score
0
Points
0
Hello again bidzey,

I have new problem with the previous contact form. I will not work on any apple computer. I really want to use a regular flash form.
I set one up so it will call the contact_form.php file you provided. However I cant get anything to send. I would really like to use your php files with my new form.

If you can figure out whats wrong, I will be forever grateful.

Here is is the site sample: http://lavida pictures.com

This is the action script i used for the form:

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( "contact_form.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 out all text fields.";
}
else if( !validate_email(contact_email.text) )
{
message_status.text = "* Please enter a 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 cannot 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);
}
}
 

vv.bbcc19

Community Advocate
Community Support
Messages
1,524
Reaction score
92
Points
48
This is a contact form that is working.You can try this.
This emails once.
 

phils13776

New Member
Messages
18
Reaction score
0
Points
0
Hello VV,

This is what i get in my squirrel mail. I just get the header no content.

Return-path: <bryanc@web4.vital.x10hosting.com>
Envelope-to: bryan@lavidapictures.com
Delivery-date: Mon, 30 May 2011 13:00:49 -0500
Received: from outgoing.x10hosting.com ([184.154.20.251])
by chopin.x10hosting.com with smtp (Exim 4.69)
(envelope-from <bryanc@web4.vital.x10hosting.com>)
id 1QR6ll-0004r9-G7
for bryan@lavidapictures.com; Mon, 30 May 2011 13:00:49 -0500
Received: (qmail 7172 invoked by uid 508); 30 May 2011 18:00:50 -0000
Received: from 10.33.248.78 by outgoing.x10hosting.com (envelope-from <bryanc@web4.vital.x10hosting.com>, uid 507) with qmail-scanner-2.08st
(clamdscan: 0.97/13130. spamassassin: 3.3.1. perlscan: 2.08st.
Clear:RC:1(10.33.248.78):SA:0(-0.6/2.8):.
Processed in 0.526921 secs); 30 May 2011 18:00:50 -0000
X-Spam-Status: No, hits=-0.6 required=2.8
Received: from unknown (HELO web4.vital.x10hosting.com) (10.33.248.78)
by outgoing.x10hosting.com with SMTP; 30 May 2011 18:00:49 -0000
Received: from bryanc by web4.vital.x10hosting.com with local (Exim 4.69)
(envelope-from <bryanc@web4.vital.x10hosting.com>)
id 1QR6ll-0008Go-Hk
for bryan@lavidapictures.com; Mon, 30 May 2011 14:00:49 -0400
To: bryan@lavidapictures.com
Subject:
From: PHPMailer@web4.vital.x10hosting.com
Reply-To:
X-Mailer: PHP/5.2.13
Message-Id: <E1QR6ll-0008Go-Hk@web4.vital.x10hosting.com>
Date: Mon, 30 May 2011 14:00:49 -0400

---------- Post added at 06:05 PM ---------- Previous post was at 06:04 PM ----------

So this form works. Just a strange output. I think the php needs values to post subject, email, message. No?

---------- Post added at 06:34 PM ---------- Previous post was at 06:05 PM ----------

I have got it to work with my form. Thank you anyway
 
Last edited:

bidzey75

New Member
Messages
53
Reaction score
0
Points
0
hey phil

sorry but I know absolutely nothing about Macs. Never even been on one. Could be something as simple as a font type being used in flash, but I really don't know. I fail to see why php would have anything to do with the type of computer being used. PHP is being processed by the same server all the time. So the issue is to find out what is happening in the hierarchy of processes that would effect a Mac over a PC. The only thing I can think of, and it might be totally irrelevant is the font setting inside the .fla file. Like I said I really don't have a clue when it comes to Apple computers.

Also if you google "flash form don't work on Macs", people are saying it's because of the flash player itself, so try to get the latest version of flash player. It's not the php code I'm pretty sure about that.
 
Last edited:
Top