NEED SERIOUS HELP // PHP & Flash

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zunskigraphics
Forum Newbie
Posts: 8
Joined: Wed Oct 26, 2005 11:11 am

NEED SERIOUS HELP // PHP & Flash

Post by zunskigraphics »

I am doing a website, that is 100% flash. I am trying to establish a submit form that sends an email with :

name
address
address2
city
state
zipcode
email

in flash my varibles are the above names with a "S" infront ("Sname", "Saddress", ect....)

Can anyone tell me how to write the PHP code for this??!?!!

you can look at the .swf here:

http://www.lancekorsun.com/FTF/freebibletext.swf


and here is the actionscripts I have assigned to my send button in the flash movie:

Code: Select all

on (release) {
sender_name = _root.Sname;       
sender_address = _root.Saddress;     
sender_address2 = _root.Saddress2;    
sender_city = _root.Scity;
sender_state = _root.Sstate;
sender_zipcode = _root.Szipcode;
sender_email = _root.Semail;
var out_lv=new LoadVars();
var in_lv=new LoadVars();
trace(sender_name);
trace(sender_address);
trace(sender_address2);
trace(sender_city);
trace(sender_state);
trace(sender_zipcode);
trace(sender_email);
out_lv.text="Sender:\n Name: "+sender_name+"\nAddress: "+sender_address+"\nAddress2: "+sender_address2+
			"\nCity: "+sender_city+"\nState: "+sender_city+"\nState: "+sender_state+"\nzip: "+sender_zipcode+
			"\nEmail: "+sender_email;
out_lv.sendAndLoad("sendemail.php",in_lv,"POST");
in_lv.onLoad=function(s){
	if(s) {trace(in_lv.ack);_root.nextFrame()}
}
}
PLEASE HELP!!!

thanks
Z

zunskigraphics@aol.com
zunskigraphics
Forum Newbie
Posts: 8
Joined: Wed Oct 26, 2005 11:11 am

Post by zunskigraphics »

i have noticed that the send button does not work in the link, but it works when I test the movie in flash??????
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I can't help you with the flash side of things but if you can manage to get the form to submit from flash to php I can help with the PHP side.

Create a file called something like "test.php" that contains just the follwoing code:

Code: Select all

<?php

if (!empty($_POST))
{

    print_r($_POST);

}
else echo "No form data submitted via POST!";

?>
Then get you flash application to submit the data to test.php and see what happens.... Once the data gets there, it'll be straight forward enough to do the email sending ;)
zunskigraphics
Forum Newbie
Posts: 8
Joined: Wed Oct 26, 2005 11:11 am

Post by zunskigraphics »

ok, so the send button now works, but i'm not sure what the test.php file does..... I did not get an email?


Thanks
Z
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

The first thing to do is make sure the php file is sending mail correctly. To do that I reccomend building an html page with the same field and form names as your flash file. Submit the html page to the PHP mailing page. If it is working great! If not fix it till it does work. Once you are sure it is working then start testing your flash movie. You are on the right track with your action script.
zunskigraphics
Forum Newbie
Posts: 8
Joined: Wed Oct 26, 2005 11:11 am

Post by zunskigraphics »

here is the php I have for this

Code: Select all

<?php
	if ($_POST)
	{
		$mailTo = "zunskigraphics@aol.com";
		$mailSubject = "[Contact] Free Bible Form - (" . $_POST['name'] . ")";
		
		$Header = "MIME-Version: 1.0\r\n";
		$Header .= "Content-type: text/html; charset=iso-8859-1\r\n";
		$Header .= "From: " . $_POST['email'] . "\r\n";
		
		$output = "<BR>";
		$output .= "From    : " . $_POST['Sname'] . "<BR><BR>";
		$output .= "Email   : " . $_POST['Semail'] . "<BR><BR>";
		$output .= "Address : " . $_POST['Smessage'] . "<BR><BR>";
		$output .= "Address2 : " . $_POST['Saddress2'] . "<BR><BR>";
		$output .= "City : " . $_POST['Scity'] . "<BR><BR>";
		$output .= "State : " . $_POST['Sstate'] . "<BR><BR>";
		$output .= "Zipcode : " . $_POST['Szipcode'] . "<BR><BR>";
		
		$output = nl2br($output);
		
		if (mail($mailTo, $mailSubject, stripslashes($output), $Header))
		{
			echo("&result=1&");
		}
		else
		{
			echo("&result=2&");
		}
	}
	else
	{
		echo("This script runs only in Flash!!!");
	}
?>
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Before you try jumping directly to sending the email, try just doing a print_r() of what is sent to the PHP script to make sure it's getting there ok :)

If it's getting there but no email appears to send then chances are it's being picked up by a spam blocker incorrectly. That's to do with the headers that mail() is sending. There's a free class you can use to send emails called phpMailer.... try that ;)
zunskigraphics
Forum Newbie
Posts: 8
Joined: Wed Oct 26, 2005 11:11 am

Post by zunskigraphics »

ok, I started from scratch, and the code for the send button is this:

Code: Select all

on (release) {
if (name eq "" or email eq "" or address eq "" or address2 eq "" or city eq "" or state eq "" or zipcode eq "") {
stop ();
} else {
loadVariablesNum ("form.php", 0, "POST");
gotoAndStop (36);
}
}
the php code i have is:

Code: Select all

<?php 
$to = "lance@lancekorsun.com"; 
$msg = "$name\n\n"; 
$msg .= "$message\n\n"; 
mail($to, $subject, $msg, "From: My web site\nReply-To: $email\n"); 
?>

ok, everything works except one thing.... in the email, i only get the first line.... the name.... i believe this has to do with the code in the php, but i am not sure where.......i uploaded the files to make it easier to understand

... http://www.lancekorsun.com/FTF/freebibletext.swf
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

in your flash code i don't see anywhere that you have a variable called message. that could for sure be the problem
zunskigraphics
Forum Newbie
Posts: 8
Joined: Wed Oct 26, 2005 11:11 am

Post by zunskigraphics »

YES !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

worked on this since 7am


THANKS EVERYONE!!!!!!!!!!!!!!

here is the code that worked

<?php
$to = "lance@lancekorsun.com";
$msg .= "$name\n\n";
$msg .= "$email\n\n";
$msg .= "$address\n\n";
$msg .= "$address2\n\n";
$msg .= "$city\n\n";
$msg .= "$state\n\n";
$msg .= "$zipcode\n\n";

mail($to, $subject, $msg, "From: My web site\nReply-To: $email\n");
?>
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post by AGISB »

Just a side question?

Why are you creating a webpage that a large number of people won't be able to see or is blocked by many?

Not even to mention disabled people or search engine placement.

Sure it is your decision but I simply don't understand doing a whole page in Flash.
Post Reply