PDA

View Full Version : Need Some Simple Mail Form Help...Please??


flash_hndikapt
12-09-2005, 05:38 PM
ok.. first let me warn you that i'm PHP retarded... so i've been pulling my hair out over this.. i created a simple contact form with a funky effect and i can't seem to collect and send the info from the input boxes in my flash file... to the PHP script, stuff it into an email, and then send back a success or error response. Could someone please take a look and help me out? Please?

I am attaching the FLA and PHP files as well as the external .as files that are needed for the FLA's effect to work. (FLA is MX04) Any help would be much much appreciated. Thanks in advance.

Cota
12-09-2005, 08:21 PM
Attached are some source files. Use it as a blue print. Remember, anything you want flash to get back, must be done with echo

flash_hndikapt
12-09-2005, 08:43 PM
thanks.. i'll take a look at them... although i have done like 30 mail form tutorials...and have successfully created mail forms before, because of the effect i applied to the mail form, i can't seem to collect and send like i normally would. I'll look over the files you attached to see if i'm missing something.

Did you happen to look at the files i attached?.. or did you just post the samples?..

flash_hndikapt
12-09-2005, 08:43 PM
thanks.. i'll take a look at them... although i have done like 30 mail form tutorials...and have successfully created mail forms before, because of the effect i applied to the mail form, i can't seem to collect and send like i normally would. I'll look over the files you attached to see if i'm missing something.

Did you happen to look at the files i attached?.. or did you just post the samples?..

Cota
12-09-2005, 08:49 PM
I looked at your examples, and the PHP file was alittle on the messy side..I'm not much of a PHP guy. I noticed in your flash file, you have this
var myVars = new LoadVars();
being declared in the onRelease function. Place that line before the onRelease function.

Flash Gordon
12-09-2005, 09:38 PM
PHP cleaned up a little

<?

//---check for hacker's and spammers
$badStrings = array("Content-Type:", "MIME-Version:", "Content-Transfer-Encoding:", "bcc:", "cc:", '\r', '\n'); // must stripslashes() of $_POST to check for \r and \n.
foreach($POST as $key => $value) {
foreach($badStrings as $value2) {
if ($value == $value2) {
exit;
}
}
}

//---------set headers
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Your Name<me@mymail.com>' . "\r\n";

//
//---------------- >> FORMATED PHP CODE << ----------------
$adminaddress = "me@mymail.com";
$siteaddress ="http://www.mysite.com";
$sitename = "mysite";
//
//change $REMOTE_ADDR to
//also add (probably right below the "no need to change" line:
$name = $_POST['name'];
$subj = $_POST['subj'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$msg = $_POST['msg'];
//---------------------------

$date = date("m/d/Y H:i:s");

if ($_SERVER['REMOTE_ADDR'] == "") {
$ip = "no ip";
} else {
$ip = getHostByAddr($_SERVER['REMOTE_ADDR']);
}

if ($action != "") { //-----WHERE IS $ACTION EVER DEFINED!!!!!!
$temp_message = "A visitor at $sitename has left the following information:\n\n
Name: $name\n
Subject: $subj\n
Email: $email\n
Telephone: $phone\n
The visitor left the following message:\n
------------------------------
$msg

------------------------------
Logged Info :
------------------------------
Using: $HTTP_USER_AGENT
Hostname: $ip
IP address: $REMOTE_ADDR
Date/Time: $date";
mail("$adminaddress","Info Request", $temp_message, $headers);

$temp_message2 = "Hi $name,\n
Thank you for your interest in $sitename's services! We will review your message and contact you to shortly.\n
Regards,
$sitename
$siteaddress"

mail("$email","Thank You for visiting $sitename", $temp_message2, $headers);
}

?>

------------------->> NOTES <<----------------
1) you should use == instead of eq in your AS
2) you don't check the input of who you are sending your mail to. Even with my code above, your script is very EASILY hacked. You should count the occurences of "@" if more that 1, exit();
3) you never echo anything in the PHP scripts, Flash can't read "minds" you have to tell if something
4) $action is never defined.

flash_hndikapt
12-09-2005, 09:49 PM
so using the php that you wrote.... if i change the AS to == as you said, the mail form should work?... because there were errors in the php script in Cota's tutorial files....

Flash Gordon
12-09-2005, 09:55 PM
I wrote that PHP script in Cota's tutorial, and I don't get any errors.

As for will it work? Did you read any of my suggestions? No! You don't output anything to the screen.

I wrote that PHP script in Cota's tutorial, and I don't get any errors. Holly Crap! Did I write that! I usually put the $ok outside of the first if() statement. Perhaps it got tweeked some :confused:
Fixed:

<?php //tells the server this is php

//-------------------------------------
// the below code set the headers. There can be a bit difficult to understand fully.
// Information about them and all the commands below can be found at the PHP manual
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Your Websites Name Here <' . $_POST['email'] . '>' . "\r\n"; //you can put your website's name in here or anything else you like
//$headers .= 'Bcc: another@email.com' . "\r\n"; //this is optional.
//------------------------------

// gets variables from flash
$to = "your@email.address"; //inset the email address it goes to here
$subject = $_POST['subject_txt'];
$message = $_POST['message_txt'];

if ($_POST['message_txt'] != "") { //this checks to make sure someone didn't visit the page manually by making sure message_txt is not empty
$ok = mail($to, $subject, $message, $headers); //this line sends the mail and returns true or false
if($ok) {
echo "&server_mes=ok&"; //if mail was send print to the screen "&server_mes=ok"
} else {
echo "&server_mes=fail&"; // if mail was NOT sent, print to the screen "&server_mes=fail"
}
}

?>// closes the php session

flash_hndikapt
12-09-2005, 10:10 PM
ok.. , maybe i should ask this question instead: could somebody PLEASE write me a php script which will collect the data from the text boxes in the file provided (without changing instance names or vars) and send an email containing that data to me, as well as a confirmation email to the sender, and send a message BACK to flash confirming or displaying error msg, making the playhead "play" so the form is reset after message is sent.

I appreciate the help you have tried to provide, but i'm am so COMPLETELY LOST when it comes to PHP.. i can't head or tails of the scripts you have tried to edit for me... truth be told.. i took that PHP script from a source file download....

can somebody help me out?... at least if i can see it done, i can start to understand how and why it works..

Flash Gordon
12-09-2005, 10:15 PM
could somebody PLEASE write me a php script which will collect the data from the text boxes in the file provided (without changing instance names or vars) and send an email containing that data to me, as well as a confirmation email to the sender, and send a message BACK to flash confirming or displaying error msg, making the playhead "play" so the form is reset after message is sent.
This is the point where you become a client and are not asking for simple help. I'm here to help and provide 2 source files, but if you want me to do your work for you, you got to have PayPal! $30 to write the scripts (including anti-spammer scripts).

Perhaps, Cota is in a more patient mood than I am.

flash_hndikapt
12-09-2005, 10:22 PM
wow.. ok, i'm completely lost now... i was trying to make some changes to the as in my FLA.. and even when i enter a valid email, address.. i get ann error telling em to enter a valid email address...

FG,
normally i WOULD NEVER ask someone to do something FOR me... but after spending 2 weeks struggling with the same file/same problem...and with me not only not "getting it", but creating NEW problems... i don't know what else to do...

flash_hndikapt
12-09-2005, 11:02 PM
ok Flash Gordon... i just lost my job and need to get this mail form working ASAP so i can find a new job before rent is due and i'm out on my ass.... Will you do it for $20????... I just need to get it done.. i can't waste anymore time getting nowhere...

This is the point where you become a client and are not asking for simple help. I'm here to help and provide 2 source files, but if you want me to do your work for you, you got to have PayPal! $30 to write the scripts (including anti-spammer scripts).

Perhaps, Cota is in a more patient mood than I am.

Flash Gordon
12-09-2005, 11:23 PM
I pm-ed you.

flash_hndikapt
12-10-2005, 12:44 AM
try this fla.. there are no #includes needed

Flash Gordon
12-10-2005, 01:49 AM
------------------->>solved<<--------------

Cota
12-10-2005, 01:55 AM
Cota is always patient....what was the solution? apparently I missed a lot..

Flash Gordon
12-10-2005, 04:35 AM
Will someone please confirm that this mail contact field works.
LINK REMOVED SINCE CONFIRMED
NOTE: That you can't see what you input! There are 4 files on the left and 1 big one on the right. The 2nd down (on the left side) is where you input your email. Underneath the box on the right (it is about 1/2 inch below the box and 1/2 inch from the right side of it) there is a invisible submit button. Press it once you put your email address in. You will simply get an email and and confirmation.

The file takes a couple of seconds to tween up to visible.

flash_hndikapt
12-10-2005, 04:43 AM
ok. Flash... yes the invisible contact form works... but HOW does that help me? this is why i said i needed a PHP script that works with my file AS IS... that's why i included the .as files that it needs to operate..

please check the form the way it is supposed to function here (http://www.artofficialintel.com/flash/MailForm/contactFixed.html)

Flash Gordon
12-10-2005, 04:47 AM
THAT IS WHAT YOU GAVE ME AND POSTED

How am I supposed to give you something else, when you only gave me the invisible form! I made work what you gave me work. What else was I supposed to do?


try this fla.. there are no #includes needed
THAT IS the file you gave me with corrected paths minus your validation that doesn't work.

Cota
12-10-2005, 04:48 AM
It works for me, I recieved the email....

flash_hndikapt
12-10-2005, 04:57 AM
correct. i gave you a file that would have an invisible form if you did not include the additional .as files that i included in the .zip file. I mentioned numerous times that those .as files needed to be put in your INCLUDES folder for the file to work properly... i didn't include them in the .zip for fun... there was a reason....stated in my original post... I even uploaded a version of the file that DID NOT REQUIRE THE #includes for you to work from... but you ignored it...

Cota; did you recieve an email using the "invisible form" or the real form?...

Flash Gordon
12-10-2005, 04:59 AM
i didn't include them in the .zip for fun.What? you got to be kidding me!
I even uploaded a version of the file that DID NOT REQUIRE THE #includes for you to work from... but you ignored it...No that is the version that I posted in the link check!

I'm gonna consider my part of the agreement done. I did what I said I would do, I wrote you a PHP code that worked with the files you gave me. If you need more help, post your problems and I'm sure someone will help you

ok. Flash... yes the invisible contact form works...Issue closed.

Cota
12-10-2005, 05:01 AM
Cota; did you recieve an email using the "invisible form" or the real form?...
I used the link Flash Gordon posted...

flash_hndikapt
12-10-2005, 05:03 AM
not true... because the one that doesn't need #includes does not display as an invisible form...

Billy T
12-10-2005, 05:07 AM
If you need more help, post your problems and I'm sure someone will help you


not if they have read this thread lol...

Cota
12-10-2005, 05:12 AM
not if they have read this thread lol...
Spoken like a prophet...

flash_hndikapt
12-10-2005, 05:16 AM
wow.. such bullsh@t. thanks for screwing over a currently unemployed graphic designer looking for help.... what a waste of money i don't have to spend... 5 hours and $30 later.. i'm right back where i started..

Cota: thank you very much for attempting to help me out... i appreciate it..

Flash Gordon
12-10-2005, 05:25 AM
CHECK THIS LINK (http://www.artofficialintel.com/flash/MailForm/contactFixed.html) Does this look like any of the files that flash_hndikapt provided to anyone?

flash_hndikapt
12-10-2005, 05:29 AM
that file is RIGHT out of my .zip file.. if you put the .as files in your includes folder..

Flash Gordon
12-10-2005, 05:38 AM
is this not all the files? That is your first posted fla. I only get the invisible swf...

If I am missing something I WILL FIX IT However, if you withheld files, that is not my fault.

POST all the files one more time the way you want it and I'll make it work.

flash_hndikapt
12-10-2005, 06:02 AM
ok.. that IS the contents of my .zip file... now.. remove the lmc_tween.as and the randomizeIt.as files from that expanded .zip folder, and place them in Flash's "includes" folder... then test the file. I assure you, the form is NOT invisible....

flash_hndikapt
12-10-2005, 06:45 AM
ok... i attached the FLA that works properly, without the use of includes... i made a few changes to the FLA similar to the changes you had made in the one you sent back.. this should work for you no matter what...

flash_hndikapt
12-10-2005, 06:54 AM
just to make it known.... this was the last correspondence between Flash Gordon and I...

Understandable and not a problem...:)

by the way..... thank you for taking the time to try to get this working for me. I do appreciate it and i apologize for my attitude earlier..... I just sort of assumed the worst, (that i was getting screwed) and reacted... i'll post a pulic forum apology as well... but thank you...

i'm not a d#ck.... honestly.... ;)

Flash Gordon
12-10-2005, 06:56 AM
HOW MANY TIMES DID I TELL YOU TO REMOVE "THIS" from your submit button????

Look it is undefined using your last posted fla. Also YOUR VALIDATION DOES NOT WORK CORRECTLY!

I told you on ever post to fix that and you haven't. The problem is your AS coding and not your php. It never was the PHP, probably.

Hope that helps :)

Good night!


stop();
var myVars = new LoadVars();
myVars.onLoad = function(success) {
if (success) {
if (myVars.server_response == "ok") {
gotoAndStop("OK");
} else {
gotoAndStop("ERROR");
}
}
};
//-------------------- >> TAB CONTROL >> -----------------------
n_mc.ipt.tabIndex = 1;
e_mc.ipt.tabIndex = 2;
p_mc.ipt.tabIndex = 3;
s_mc.ipt.tabIndex = 4;
m_mc.imt.tabIndex = 5;
//
// -------------------- >> SUBMIT BUTTON >> --------------------
submit_btn.writeIt("submit form");
//
submit_btn.onRelease = function() {
u_name = n_mc.ipt.text;
u_email = e_mc.ipt.text;
u_phone = p_mc.ipt.text;
u_subj = s_mc.ipt.text;
u_msg = m_mc.imt.text;
// Check variable data
if (u_name eq "" || u_name eq "Name...") {
stat.clearIt("Enter Name", 50);
} else if (u_subj eq "" || u_subj eq "Subject...") {
stat.clearIt("Enter Subject", 50);
//} else if (u_email eq "" || u_email eq "Email...") {
//stat.clearIt("Enter Email Address", 50);
//} else if (!u_email.length || u_email.indexOf("@") == -1 || u_email.indexOf(".") == -1) {
//stat.clearIt("Enter Valid Email Address", 50);
} else if (u_msg eq "" || u_msg eq "Message...") {
stat.clearIt("Enter Message", 50);
} else {
myVars.subj = u_subj;
myVars.name = u_name;
myVars.email = u_email;
myVars.msg = u_msg;
myVars.phone = u_phone;
trace(myVars);
myVars.sendAndLoad("mail.php", myVars, "POST");
stat.clearIt("Sending... Please Wait...", 50);
//this.gotoAndPlay("sending");
// go to a loop somewhere until returned that msg sent successfully....
// then reset the fields and return to form.
}
};
// -------------------- >> RESET BUTTON >> -------------------
reset_btn.writeIt(" reset form");
//
reset_btn.onRelease = function() {
stat.clearIt("Form Fields Reset...", 30);
n_mc.writeIt("Name...");
e_mc.writeIt("Email...");
p_mc.writeIt("Phone...");
s_mc.writeIt("Subject...");
m_mc.writeIt("Message...");
};

flash_hndikapt
12-10-2005, 07:11 AM
where did i use "this" on my submit button?.. except to tell the main timeline to move?...
and the only reason the validation is there, is because i took the original file that was in the .zip and just included the necessary AS to make it w0ork wothout the #include files..


FYI.. the code posted above spits back this message in the output panel:

**Error** Scene=Scene 1, layer=ACTIONS, frame=4:Line 4: Operator '=' must be followed by an operand
* * if (success) {

**Error** Scene=Scene 1, layer=ACTIONS, frame=4:Line 5: Syntax error.
* * * * if (myVars.server_response == "ok") {

**Error** Scene=Scene 1, layer=ACTIONS, frame=4:Line 6: Syntax error.
* * * * * * gotoAndStop("OK");

**Error** Scene=Scene 1, layer=ACTIONS, frame=4:Line 7: Syntax error.
* * * * } else {

Total ActionScript Errors: 4 Reported Errors: 4

Flash Gordon
12-10-2005, 07:13 AM
submit_btn.onRelease = function() {
u_name = this.n_mc.ipt.text;
u_email = this.e_mc.ipt.text;
u_phone = this.p_mc.ipt.text;
u_subj = this.s_mc.ipt.text;
u_msg = this.m_mc.imt.text;BAD!

flash_hndikapt
12-10-2005, 07:16 AM
WHY BAD?....

wait... "this.blahg blahg blah.. ok.. i'm retarded...

sorry.. that's my bad...

submit_btn.onRelease = function() {
u_name = this.n_mc.ipt.text;
u_email = this.e_mc.ipt.text;
u_phone = this.p_mc.ipt.text;
u_subj = this.s_mc.ipt.text;
u_msg = this.m_mc.imt.text;BAD!

Billy T
12-10-2005, 07:19 AM
because the path causes flash to look inside the submit button for the text boxes...which is not where they exist

Flash Gordon
12-10-2005, 07:21 AM
u_name = this.n_mc.ipt.text is equal to u_name = submit_btn.n_mc.ipt.text

I think I can safely say, I did my part here (several times). If you actually take my suggestions that I gave to you for your actionscript (which I will be sending the bill to you for that :p ) if would have worked in the first place. I told you that in the first PM.

LINK GONE
remember, the original deal was for me to provide the PHP scripting (not AS) and not any graphical interace. this include a confimation sections that you don't have.

Problems: In you FLA on your submit button, you must get rid of "this". It cause path problems. Also, I deleted you validation. It is not working correctly, however I didn't fix it because that wasn't our deal. Just add it back in when you are ready. Also, I took out your text varibles. That is VERY OLD syntax, and is really no longer supported.

Please feel free to ask if you have any specific questions. I prefer them to be in the form though.

Good luck.
FG

Any paypal donations are gracious accepted. :)

My work is done.

flash_hndikapt
12-10-2005, 07:22 AM
ok.. got the whole "this" issue.. i understand that. but the syntax for the (success) function looks correct... why is flash spitting back errors?...

flash_hndikapt
12-10-2005, 07:27 AM
OH MY GOD..... i've turned into the client that i loath.........how have i come to this?... i suck.. i'm sorry.... go to bed, thanks again for your help. I gota take my dog for a walk before i crash for the night... hopefully i can make it all work in the morning...

flash_hndikapt
12-10-2005, 07:58 AM
AH ha!!!! i got it working... thank friggin god. or perhaps.. thank friggin Flash Gordon is more appropriate.. either way. it works. thanks.

Flash Gordon
12-10-2005, 03:08 PM
i wonder what the problem could have been :D

As you can see attached, I get no errors when copied and pasted from my earlier post.

Since all the extra hassle (6 hours which the solution goes back to my original statement of "this"), perhaps you would be willing to throw some (back end) work my way (for you or any of your clients as needed). Let me know if you want to track users in your Flash site. I could set it up with a database and one php script.

flash_hndikapt
12-10-2005, 05:42 PM
i went back an reconstructed the file from scratch, and then went through line by line adding the AS... sometimes copying and pasting code from the web adds weird hidden characters.. i think that may have been the problem. I will keep you in mind as far as back-end work goes, i have a few projects coming up that may require more than i can handle... thanks again for your help.