Sending e-mail with check-boxes.

  • x2pher
  • Newbie
  • Newbie
  • User avatar
  • Posts: 6
  • Loc: Norway

Post 3+ Months Ago

Hi,

I'm working on a contact form in flash which sends all the data to my e-mail. Usually I haven't had any problems with making such a form, but now I'm stuck. I'm planning to use "check boxes" in my new form, but how do you include that in the AS? Now I'm using the code that I found at Gotoandlearn.com:

stop();

var senderLoad:LoadVars = new LoadVars();
var receiveLoad:LoadVars = new LoadVars();

sender.onRelease = function() {
senderLoad.theName = theName.text;
senderLoad.theEmail = theEmail.text;
senderLoad.theMessage = theMessage.text;
senderLoad.sendAndLoad("http://www.daae.co.uk/send.php",receiveLoad);
}

receiveLoad.onLoad = function() {
if(this.sentOk) {
_root.gotoAndStop("success");
}
else {
_root.gotoAndStop("failed");
}
}

The PHP file looks like this:

<?PHP

$to = "myemail@mydomain.com";
$subject = "Contact form";
$message = "Name: " . $theName;
$message .= "\nEmail: " . $theEmail;
$message .= "\n\nMessage: " . $theMessage;
$headers = "From: $theEmail";
$headers .= "\nReply-To: $theEmail";

$sentOk = mail($to,$subject,$message,$headers);

echo "sentOk=" . $sentOk;

?>

How can I add check boxes to this code, if it's possible? I believe I'm what you call a newbie, so I appreciate any help I can get :)
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • x2pher
  • Newbie
  • Newbie
  • User avatar
  • Posts: 6
  • Loc: Norway

Post 3+ Months Ago

bump
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

:D
i supose you want to add check boxes to your flash form.
If that`s the case, either use the existing control for checkbox from macromedia flash, or create your own checkbox.
Either way, you just pass as parameter the value of the checkbox (true -> if checked, false if unchecked).
so will be something like:
Code: [ Select ]
senderLoad.theCB1 = checkBox1.checked;
senderLoad.theCB2 = checkBox2.checked;
  1. senderLoad.theCB1 = checkBox1.checked;
  2. senderLoad.theCB2 = checkBox2.checked;


and in php:
Code: [ Select ]
if ($theCB1)
 { // do something
  }
if ($theCB2)
 { // do something
  }
  1. if ($theCB1)
  2.  { // do something
  3.   }
  4. if ($theCB2)
  5.  { // do something
  6.   }
  • x2pher
  • Newbie
  • Newbie
  • User avatar
  • Posts: 6
  • Loc: Norway

Post 3+ Months Ago

Yes, I want to add check boxes :)

Now I'm trying to use the components which is intergrated in flash. I've tried to add the code you submitted to AS and the PHP, but nothing happend. The instance name for the check boxes should be like you wrote; theCB 1 & theCB2, right?

Discovered another problem when trying to send the text to my email. The text i submitted wasn't sent at all.. Just blank spaces...

Do anyone have a tutorial or a specific code I can use to make this work? Been working on this form for several days now and I'm getting a little frustrated - hehe..
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

hehehe
of course you got nothing, since in that php form you didnt get the variables ($theName = $_POST["theName"]; .... )
here you have a nice example
send email from flash using php
  • x2pher
  • Newbie
  • Newbie
  • User avatar
  • Posts: 6
  • Loc: Norway

Post 3+ Months Ago

Hehe.. Well, as I said: newbie :D ...

But I have tried to build up the contact form from kirupa. If we use that or the code I wrote in the beginning as an example, how can I add check boxes to it? How should the AS code and the PHP code be? Googled around and I have noe idea :(...
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

add the checkboxes, and POST their check status to the php file (along with the other variables), just like i wrote before
  • x2pher
  • Newbie
  • Newbie
  • User avatar
  • Posts: 6
  • Loc: Norway

Post 3+ Months Ago

Tried around for some hours now, and 'm still not getting it right. I've manged to get the script to send me an email now, but now all i get is a blank mail. Do you know what can cause this?

This is the code I'm using for the AS now:

Quote:
stop();

var senderLoad:LoadVars = new LoadVars();
var receiveLoad:LoadVars = new LoadVars();

sender.onRelease = function() {
senderLoad.theName = theName.text;
senderLoad.theEmail = theEmail.text;
senderLoad.theMessage = theMessage.text;
senderLoad.checkBox = checkBox.checked;
senderLoad.sendAndLoad("http://www.mydomain.com/send.php",receiveLoad);
}

receiveLoad.onLoad = function() {
if(this.sentOk) {
_root.gotoAndStop("success");
}
else {
_root.gotoAndStop("failed");
}
}


And this is for the php-code:

Quote:
<?PHP

$to = "nickname@gmail.com";
$subject = 'Skjema';
$theName = $_POST["Name: "];
$theEmail .= $_POST["\nEmail: "];
$theMessage .= $_POST["\n\nMessage: "];
$checkBox = $_POST['checkBox'];
$headers = "From: $theEmail";
$headers .= "\nReply-To: $theEmail";

$sentOk = mail($to,$subject,$message,$headers);

echo "sentOk=" . $sentOk;

?>


Am I still doing all wrong? Why won't it work :(
  • x2pher
  • Newbie
  • Newbie
  • User avatar
  • Posts: 6
  • Loc: Norway

Post 3+ Months Ago

Wow... Just got it right, for some reason. Had to change the code alot, but finally I've got it right. Learn by doing I guess. Thanks for all the help.
  • sandpetra
  • Newbie
  • Newbie
  • sandpetra
  • Posts: 13
  • Loc: Scotland

Post 3+ Months Ago

Superb! Is this bit of code 'accessible'?

Post Information

  • Total Posts in this topic: 10 posts
  • Users browsing this forum: No registered users and 10 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.