;

PDA

Click to See Complete Forum and Search --> : Code Check Please...


dniezby
12-17-2006, 04:11 AM
It's for a eMail form. It used to work but for some reason, it's not working now...Let me rephrase, it does still send the eMail but it's not getting a returning variable, so it will go to the "Thank You" page.

I've looked over the code for hours and can't seem to get it to return the variable...What's weird is that I used this code for the contact form on http://www.nssclan.org and that one suddenly doesn't work either....It did the other day.

Could someone look over the code and see if there is something wrong with it? I wrote this code with Chris' help in when version 4 was out.

Here is the code in the frame of the form.

// Check for blank fields and submit
sendbutton.onRelease = function(){
if(fullname.text == ""||email.text==""||agree.text==""||lastname.text==""||dob.text==""||gbname.text==""||eseal.text==""){
// If any of the fields are blank
errormessage._x = 150;
errormessage.gotoAndPlay("go");

}else{
var result_lv = new LoadVars();
result_lv.onLoad = function(success){
if(success){
fullname.text="";
lastname.text="";
email.text="";
dob.text="";
gbname.text="";
eseal.text="";
agree.text="";
myresponse.text = result_lv.returnMe;
gotoAndPlay("thanks");

}else{
myresponse.text = "error"
unknown_error._x = 150;
unknown_error.gotoAndPlay("go");
}
}
}
// Send the Data
var send_lv = new LoadVars();
send_lv.action = "send";
send_lv.fullname = fullname.text;
send_lv.lastname = lastname.text;
send_lv.email = email.text;
send_lv.dob = dob.text;
send_lv.gbname = gbname.text;
send_lv.eseal = eseal.text;
send_lv.agree = agree.text;
send_lv.subject = subject.text;
send_lv.recipient = recipient.text;
send_lv.sendAndLoad("clanrequest.php",result_lv,"POST");
};

Here is the php code for reading the submission data, sending the email and sending reply back to my movie.
clanrequest.php
<?

$fullname = $_POST["fullname"];
$lastname = $_POST["lastname"];
$email_addy = $_POST["email"];
$dob = $_POST["dob"];
$gbname = $_POST["gbname"];
$eseal = $_POST["eseal"];
$agree = $_POST["agree"];
$subject = $_POST["subject"];
$recipient = $_POST["recipient"];
$action = $_POST["action"];


// Log the IP address of sender
$ip = $_SERVER['REMOTE_ADDR'];
$date = date("m/d/Y H:i:s"); // Date the form was sent



if ($action == "send") {
mail ("$recipient","$subject",
"A visitor has requested to join your clan:\n

From: $lastname, $fullname
eMail: $email_addy
GB Name: $gbname
eSeal name: $eseal
DOB: $dob

$agree, I agree to the clan rules and code of conduct.



Logged Info :
------------------------------
Using: $HTTP_USER_AGENT
IP address: $ip
Date/Time: $date", "FROM:$email_addy") ;

}
echo "&returnMe=thanks";

?>

Stoke Laurie
12-17-2006, 08:42 AM
<?
ini_set("sendmail_from", " admin@allabouthere.co.uk "); //configure this to you
//LoadVar_Mailform for Koolmoves © 2006 Chris Seahorn (http://sandbox.blogdns.com//cjseahorn@aim.com)
$fullname = $_POST["fullname"];
$lastname = $_POST["lastname"];
$email_addy = $_POST["email"];
$dob = $_POST["dob"];
$gbname = $_POST["gbname"];
$eseal = $_POST["eseal"];
$agree = $_POST["agree"];
$subject = $_POST["subject"];
$recipient = $_POST["recipient"];
$action = $_POST["action"];


$ip = $_SERVER['REMOTE_ADDR'];

$adminaddress = "you@yourwebaddress.com"; //configure this to you
$siteaddress ="your web address"; //configure this to you
$sitename = "Your Site Name"; //configure this to you

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

$action = $_POST["action"];


if ($action == "send") {
mail ("$adminaddress","A visitor has requested to join your clan\n",

From: $lastname, $fullname
eMail: $email_addy
GB Name: $gbname
eSeal name: $eseal
DOB: $dob

$agree, I agree to the clan rules and code of conduct.


Logged Info :
------------------------------
Using: $HTTP_USER_AGENT
IP address: $ip
Date/Time: $date","FROM:$adminaddress" ) ;



//Confirmation is sent back to the Flash form that the process is complete

echo "&returnMe=thanks";



}


?>

blanius
12-17-2006, 02:08 PM
Looked to me like you should define result_lv here

var send_lv = new LoadVars();
var result_lv=new LoadVars();
send_lv.action = "send";
send_lv.fullname = fullname.text;
send_lv.lastname = lastname.text;
send_lv.email = email.text;
send_lv.dob = dob.text;
send_lv.gbname = gbname.text;
send_lv.eseal = eseal.text;
send_lv.agree = agree.text;
send_lv.subject = subject.text;
send_lv.recipient = recipient.text;
send_lv.sendAndLoad("clanrequest.php",result_lv,"POST");
};

dniezby
12-17-2006, 04:29 PM
Looked to me like you should define result_lv here

var send_lv = new LoadVars();
var result_lv=new LoadVars();
send_lv.action = "send";
send_lv.fullname = fullname.text;
send_lv.lastname = lastname.text;
send_lv.email = email.text;
send_lv.dob = dob.text;
send_lv.gbname = gbname.text;
send_lv.eseal = eseal.text;
send_lv.agree = agree.text;
send_lv.subject = subject.text;
send_lv.recipient = recipient.text;
send_lv.sendAndLoad("clanrequest.php",result_lv,"POST");
};

NO, that change caused the form to not even send the data. Probably because I already called this function in the IF statement.

Stoke Laurie
12-17-2006, 05:28 PM
Go back to Koolexchange and download Chris's loadvars again.
Change the field names to what you need and the code to match, If I can suggest that you stick to Chris's convention of calling the fields box1 and box2 etc, you will find it easy to trace them through your actionscript and then the php.
I just added this line
ini_set("sendmail_from", " admin@allabouthere.co.uk "); because some servers require this as authority to POST.

dniezby
12-17-2006, 08:22 PM
Go back to Koolexchange and download Chris's loadvars again.
Change the field names to what you need and the code to match, If I can suggest that you stick to Chris's convention of calling the fields box1 and box2 etc, you will find it easy to trace them through your actionscript and then the php.
I just added this line
ini_set("sendmail_from", " admin@allabouthere.co.uk "); because some servers require this as authority to POST.

I put this in the PHP, but that didn't work either.

You know what pisses me off? It USED to work. I didn't change anything except add fields. I've looked over Chris' code and it's the same.

I just wish I knew "where" the error was. I think it's in the PHP echoing back...
Any thoughts on how I can test to see if it really is echoing out?

blanius
12-17-2006, 10:15 PM
call the PHP file directly in the browser. Also I'm willing to bet it's in the actionscript and has to do with differences in flash 8, which would explain why it stopped working as that probably is something that DID change.

dniezby
12-18-2006, 01:04 AM
You're right, the PHP returns correctly...

Hmm, then I wonder what the heck I can do now.

The whole issue isn't the actual sending of the form. That works fine. I was using the return value to wait for confirmation from the PHP then move on to the thankyou page.

Any thoughts?

Stoke Laurie
12-18-2006, 03:34 PM
Why don't you try Chris's as a control by loading his swf and php to your server, assuming the echo is returned you then know you have a version that does what you want, all you then need to do is redress the swf to look the way you want it to, leave the variable the way Chris created them and simply change the text boxes to reflect what you want them to type in.

dniezby
12-18-2006, 04:45 PM
Well, I figured out the problem.

It seems that the return variable may have been getting stuck elsewhere in the movie.

The problem was here:


myresponse.text = result_lv.returnMe;
gotoAndPlay("thanks");


And here is the solution:


_root.gotoAndPlay("thanks');


Something must have changed in Flash 8 to make me have to specify that the returning variable needed to go back to the root.

You can see the live form at
http://www.nssclan.orgl Then click the JOIN US button.
Just put DEMO in for your email address if you're goint to try it. All the cool stuff happens after you send the form.
NOTE: JUST IN CASE THE FORM DOESN'T OPEN, (I'M TESTING SOME JAVASCRIPT TO OPEN THE FORM IN A NEW WINDOW) You can go directly to the form at http://www.nssclan.org/forms/joinclan.html

Stoke Laurie
12-18-2006, 05:22 PM
Excellent glad you found the answer. Tried the form very good.
If I were you I would check the point size or the size of the text fields that you fill in as the text seemed too big for the box. By the way why not just use a _blank url link from the main swf to the forms page?

dniezby
12-18-2006, 06:17 PM
Excellent glad you found the answer. Tried the form very good.
If I were you I would check the point size or the size of the text fields that you fill in as the text seemed too big for the box. By the way why not just use a _blank url link from the main swf to the forms page?

I did that but it just opens a new window and not a specific sized window.

dniezby
12-18-2006, 10:31 PM
Excellent glad you found the answer. Tried the form very good.
If I were you I would check the point size or the size of the text fields that you fill in as the text seemed too big for the box. By the way why not just use a _blank url link from the main swf to the forms page?

Fixed the text boxes and now the form opens correctly. I hope you have a chance to check it out again.

Stoke Laurie
12-20-2006, 12:09 PM
Yep works fine now well done.

dniezby
12-20-2006, 01:15 PM
Check out the Profiles Folder - The data isn't there yet but the graphics and animation are...What do ya think?