PHP form, checkboxes, and stuff

Hello. I am havign a few issues with doing a flash form using PHP. First of all, the way the form is set up, I have a few input text feilds, a few checkbox components, and clear and submit buttons. I am having several problems.

First of all, when I clear the checkboxes, it visually clears them, but it doesn’t clear the data, because if I fill out the form and check the boxes, and then clear it, and then send it with only one or no boxes checked, I still get the data in the PHP email. Here is the AS i am using:

(Just a quick update, apparently, also, if i check the box and then uncheck it again, it also registers as having been checked anyways)

on the checkboxes:

on (press){
_global.web = this.getValue();
if (_global.web = O) {
_global.web = “Website”;
} else {
_global.web = null;
}
}

on the clear button:

web.setValue(0);

on the submit button:

web = _global.web
loadVariablesNum(“form.php”, “0”, “POST”);

Also, my second problem is I am trying to send a message back to flash from the PHP into a dynamic text box in the form saying Thanks, blah blah. and that isn’t working either. the entire form is contained within a MC called ContactMC. the textbox’s variable is “status”. This is the line I have in the PHP after the mail bit:

Print “_root.ContactMC.status=Your form has been sucessfully sent. Thank you!”;

If anyone coudl help me with these issues I would be soooooooooo much less stressed…lol.
If you need me to post a fla, let me knwo and I will.
Thanks!!

:slight_smile:

would you post your fla? With problems like these, we sometimes have to recreate the whole thing. Then again, someone might take a look and say “there’s the problem”. In either case, it helps to get a better look.

sure, ill post the fla and the php. :slight_smile:

here is the php

woops!!! i jsut noticed, int he PHP, the one i uploaded is a little different from the one i was using…

in the last line, it should read

Print “_root.contentContactMC.status=Your form has been sucessfully sent. Thank you!”;

sorry!

p.s. Inigo is like my ALL TIME favorite dude to quote…
:beam:

>=]

anyone? i hate to be a pain in the arse… but if i dont have this by tomorrow my butt is grass. i’ve been puttering around with it and still haven’t figured it out. grr.

Hey, golgi… I’ll try to take a look, but Im not sure if I’ll have for you before you need it. Check back late (really late). Can’t promise anything though, I have some deadlines myself.

:wink:

the problem is probably that you have global variables turned off on your server, a simple fix is this:

http://www.kirupaforum.com/forums/showthread.php?s=&threadid=15399&highlight=%24POST

wait a sec, jubba, you mean like put this
$Subject_=_$_POST[‘Subject’];

$Body_=_$_POST[‘Body’];

$MailFrom_=_$_POST[‘MailFrom’];

at the top of the PHP?

yeha you would put that at the top of the php file for each variable in your flash movie. I didn’t look at your fla but say you had the variables: “junk” “munk” & “punk”

you would do this in the php file:


$junk = $_POST['junk'];
$munk = $_POST['munk'];
$punk = $_POST['punk'];

// The rest of your code would go here....

hrm, i jsut tried it and the form didnt work at all then. oen ques, and this si gonna sound really dumb, but what issue is this trying to fix? the checkboxes?

I see single equal sign in your if statement and no quotes around O… if you didn’t fix it yet, you will need to fix it though…
if (_global.web = O) {
to
if (_global.web == “O”) {

ok, CyanBlue, that almost worked. i changed the code to
on (press){
_global.web = this.getValue();
if (_global.web == “O”) {
_global.web = “Website”;
} else {
_global.web = null;
}
}

but then i kept getting null printed in the email for everything. so then, i switched it around to

on (press){
_global.web = this.getValue();
if (_global.web == “O”) {
_global.web = null;
} else {
_global.web = “Website”;
}
}

then it was back to the original problem again. did i miss something?

ok, here i am again, 2 am, still working on this. but the good news is i have resolved almost all of the issues.
first off, i gave up on getting the “Thank you” printed from the PHP back into flash, instead I just made it go to a new frame with a thank you on it. Also, as for the clicking the checkboxes and getting rid of the values, this is what I did. Now you can check the checkbox, and then uncheck it, and it clears it for real
on the checkbox:

on (press){
_global.web == this.getValue();
if (_global.web == “O”) {
_global.web = null;
} else if (_global.web == “1”) {
_global.web = “Website”;
}
}

Also, I have managed to get it so that if you click on the clear button, it also clears it. this is what I have on the clear button:

_global.web = “”;
web.setValue(0);

so that’s pretty much it. i’m sure my code is sloppy, and there must be a better way, but it works for now, so it’s good for me! i appreciate all your help guys. :slight_smile: and if anyone figures out how to make the PHP make text back into flash, i would love to see your solution.

thanks thanks thanks
:beam:

>=]

your problem might also come from using web both as _global.web and just web, the thing is that for Flash, once you’ve used _global.web once, it considers “web” as a global var, it’s then the same to use either, and I guess you were trying to use web for another purpose than _global.web…? clear?
always best when using globals to put a distinctive letter before, like gWeb…

Ahhh, good point. Thank you eyez :slight_smile:

I’m glad you got it working…

I have tried your code a while ago and used LoadVars() object instead of loadVariablesNum() function… and I do get the word from PHP script…

Else block of the button…

	else
	{
//		loadVariablesNum("form.php", "0", "POST");
		sendLVs = new LoadVars();
		sendLVs.name = this.name;
		sendLVs.firm = this.firm;
		sendLVs.phone = this.phone;
		sendLVs.email = this.email;
		sendLVs.type = this.type;
		sendLVs.anim = this.anim.getValue();
		sendLVs.vid = this.vid.getValue();
		sendLVs.vid2 = this.vid2.getValue();
		sendLVs.web = this.web.getValue();
		status = "Sending..." + name + " : " + firm + " : " + phone + " : " + email + " : " + type + " : " + anim.getValue() + " : " + vid.getValue() + " : " + vid2.getValue + " : " + web.getValue();
		sendLVs.onLoad = function ()
		{
			status = sendLVs.status;
			this.name = "";
			this.firm = "";
			this.phone = "";
			this.email = "";
			this.type = "";
			this.anim.setValue(false);
			this.vid.setValue(false);
			this.vid2.setValue(false);
			this.web.setValue(false);
		}
		sendLVs.sendAndLoad("http://localhost/golbi/form.php", sendLVs, "POST");
	}

PHP code…

<?
	$name = $_POST['name'];
	$firm = $_POST['firm'];
	$phone = $_POST['phone'];
	$email = $_POST['email'];
	$type = $_POST['type'];
	$anim = $_POST['anim'];
	$vid = $_POST['vid'];
	$vid2 = $_POST['vid2'];
	$web = $_POST['web'];
	
	$to = "wooliesock@yahoo.com";
	$subject = "CRT Form";
	$msg = "Sent by: $name

";
	$msg .= "Law firm: $firm

";
	$msg .= "Phone number: $phone

"; 
	$msg .= "Email: $email

"; 
	$msg .= "Type of Trial: $type

";  
	$msg .= "Projects Interested in:

";
	$msg .= "$anim

"; 
	$msg .= "$vid

"; 
	$msg .= "$vid2

"; 
	$msg .= "$web

"; 
	mail($to, $subject, $msg, "From: $name
Reply-To: $email
");
	print "status=Your form has been sucessfully sent. Thank you!";
?>

Notice that I got rid of _root part in the PHP script…

Can you post your file one more time??? I can’t get this radio buttons working… :frowning:

Well… Good night… Gotta get some sleep… :wink:

i must be the dumbest person ever. oi. here’s the thing. i THOUGHT i got it working, but i guess since it was like 4 am, i overlooked soemthing big. hehe. yeha, when you pressed clear, or unchecked the checkbox, nothing showed up in the email, like i wanted it to. but apparently, when you CHECK the checkbox, nothing showed up in it either! so i have decided to start from square 1 again. i tried doing it a different method by following a tut on macromedia and making a function for when the box is pressed instead of doing on (press), but that didnt work. then i tried your code, cyanblue, and that didn’t work for me either! which means, that it HAS to be something i am fudging up, because obviously it worked for you…

ok, editing… new progress. i got the darn thing to work. everything works. except for when it goes to the email, it says “true” or “false” instead of animation or nothing, but i’m pretty sure i can fix that. if i get stuck i’ll post again… until then, wish me luck (-: