PDA

View Full Version : Flash mail form php with checkboxes



cyberkaly
March 5th, 2007, 07:30 AM
Hi all,


I have created a mail form with flash which gives the data to an php file and sends it to my email, the problem is that it works on the inputboxes, just it doesnt sends the value of the checkboxes.

the instacnes of the checkobxes are checkbox1, checkbox2 etc..
and the variable is myCheckbox

if I use the loadvars Object it doesnt work

<?php
$sendTo = "kalyan@mukherjee.ch";
$subject = "My Flash site reply";

$headers = "From: " . $_POST["name"]." ". $_POST["course"] . "<" . $_POST["email"] .">\r\n". $_POST["dob"] ." " . $_POST["yos"] ." " . $_POST["phone"] ." " . $_POST["address"] .">\r\n";
$headers .= "<" . $_POST["email"] . ">\r\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$headers .= "Return-Path: " . $_POST["email"];
$headers .= "Ticked: " . $_POST["myCheckbox"];

mail($sendTo, $subject, $headers);
?>

can anyone help me how to work out the problem?

thanks!!!

this.me
March 5th, 2007, 08:40 AM
make sure you did not make any mistakes with the typing!

in the variablebox as well in the actionscripting and the php..

Ofcourse anyone would know but it's my most common fault.:wt:

edit: can you post the actionscript?

cyberkaly
March 6th, 2007, 05:42 AM
the script is:

stop ();
var ck1:mx.controls.CheckBox;
var ck2:mx.controls.CheckBox;
var myCheckbox:String;
var lv:LoadVars;
lv = new LoadVars ();
var lvAnswer:LoadVars;
lvAnswer = new LoadVars ();
myCheckbox = "not selected";
var checkListener:Object = new Object ();
checkListener.click = function () {

if (ck1.selected) {
myCheckbox = "isSelected";
} else {
myCheckbox = "not selected";
}
};
submitBut.onRelease = function () {
lv.myCheckbox = myCheckbox;
lv.sendAndLoad ("email.php", lvAnswer, "POST");
};
};

this.me
March 6th, 2007, 06:25 AM
strange...

i can't see any problem either..

mmm..

sorry

cyberkaly
March 6th, 2007, 05:12 PM
strange...

i can't see any problem either..

mmm..

sorry


ok I can give you some more infos, and u can have a look at the fla file? download it at www.mukherjee.ch/cuflash8.fla (http://www.mukherjee.ch/cuflash8.fla)

the instance names of the Checkboxes are: ck1-ck3
and the script to get the value is
stop ();
//Sets value for checkbox
ck1.name = 'checkbox1';
ck2.name = 'checkbox2';
ck3.name = 'checkbox3';

on the submit button the script is
on (release) {
var checkbox1:mx.controls.CheckBox;
var checkbox2:mx.controls.CheckBox;
var checkbox3:mx.controls.CheckBox;

mylv = new LoadVars();
mylv.checkbox1 = checkbox1;
mylv.checkbox2 = checkbox2;
mylv.checkbox3 = checkbox3;
// send variables in form movieclip (the textfields)
// to email PHP page which will send the mail
form.loadVariables("email.php", "POST");
}

I changed the script a bit... on the php file:
<?php
$sendTo = "kalyan@mukherjee.ch";
$subject = "CU FORM REPLY";

$headers = "From: " . $_POST["name"]." ". $_POST["course"] . "<" . $_POST["email"] .">\r\n". $_POST["dob"] ." " . $_POST["yos"] ." " . $_POST["phone"] ." " . $_POST["address"] .">\r\n";
$headers .= "<" . $_POST["email"] . ">\r\n";
$data = "Checked: " . $POST["checkbox1"] ." " .$_POST["checkbox2"] ." " . $_POST["checkbox3"] .">\r\n";
mail($sendTo, $subject, $headers, $data);
?>

when I changed $data to $headers it worked that the title would send me by email but the values wont, and all other values would come either.

this.me
March 7th, 2007, 03:38 AM
i checked the files..

you have to give values with the checkboxes if they are checked and unchecked..

Because it doesn't recorgnize both..

in a php contact form tut here on kirupa (link (http://www.kirupa.com/web/php_contact_form3.htm)) the give values like always in html forms

but you also have to do that in flash with actionscript.
try pressing F1 in flash and find some info about the use of checkboxes..

aaadar
March 12th, 2007, 10:50 AM
Trying to send email form data,

but all I get in the email returned is

[Object] [Object]

=============
I combined Kirupa's components to create a form and Email Form with PHP, got the form working, it sends through email, but comes back as indicated above

Can anyone assist
Attached fla

============================

Code for form
--------------------
// The display function
function radioDisplay (component) {
radio = component.getValue() ;
trace ( radio ) ;
}
// We assign this function to the group gender
kindofkid.setChangeHandler ("radioDisplay") ;
buycar.setChangeHandler ("radioDisplay") ;

// populate the combobox
/*for (i=1;i<3;i++) {
gender.addItem (i) ;
}*/
// function to display the selection
function comboDisplay (component) {
combo = component.getSelectedItem().label ;
trace ( combo );
}
// We assign the function to the combobox
gender.setChangeHandler ("comboDisplay") ;



**************

Code for submit
--------------------------
on (press) {
// send variables in form movieclip (the textfields)
// to email PHP page which will send the mail
this.form.loadVariables("email.php", "POST");
}

on (release) {
// send variables in form movieclip (the textfields)
// to email PHP page which will send the mail
gotoAndPlay(30);
}


**********************


Code for email.php
------------------------

<?php
/************************************************** *\
* PHP 4.1.0+ version of email script. For more
* information on the mail() function for PHP, see
* http://www.php.net/manual/en/function.mail.php
\************************************************* **/


// First, set up some variables to serve you in
// getting an email. This includes the email this is
// sent to (yours) and what the subject of this email
// should be. It's a good idea to choose your own
// subject instead of allowing the user to. This will
// help prevent spam filters from snatching this email
// out from under your nose when something unusual is put.

$sendTo = "andrew@intetech.co.za";
$subject = "CJD Emailer result";

// variables are sent to this PHP page through
// the POST method. $_POST is a global associative array
// of variables passed through this method. From that, we
// can get the values sent to this page from Flash and
// assign them to appropriate variables which can be used
// in the PHP mail() function.


// header information not including sendTo and Subject
// these all go in one variable. First, include From:
$headers = "From: CJD Website \r\n";
// next include a replyto
$headers .= "Reply-To:andrew@intetech.co.za \r\n";
// often email servers won't allow emails to be sent to
// domains other than their own. The return path here will
// often lift that restriction so, for instance, you could send
// email to a hotmail account. (hosting provider settings may vary)
// technically bounced email is supposed to go to the return-path email
$headers .= "Return-path:andrew@intetech.co.za";

// now we can add the content of the message to a body variable
$message = "Gender| " . $_POST["gender"] ." Race| ". $_POST["race"] . "Income| "
. $_POST["income"] . "Buycar| ". $_POST["buycar"] ."Kind of kid| ". $_POST["kindofkid"] ."\r\n";


// once the variables have been defined, they can be included
// in the mail function call which will send you an email
mail($sendTo, $subject, $message, $headers);

?>

******************

deletedUser2352352
March 13th, 2007, 05:12 AM
I dunno if this would help but its happened to me a few times.

in flash the part the you place the email.php call try using its full url. Sometimes and i say somtimes flash messes me up on that.