Sending variables from flash to PHP, calculating..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Sending variables from flash to PHP, calculating..

Post by Steveo31 »

I'm back :)

Trying out a poll system, nothin fancy, and for no reason, really. But I am having a brain-lapse, and am in need of some assistance. Here's the code in the Flash file:

Code: Select all

poll = new LoadVars();
pollURL = "http://d6c3z021/polltest.php";

//the above is the addy for the apache I have installed.

function submitForm() {
	choice = radioGroup.getData();
	poll.load(pollURL+"?choice="+choice);
}
And on the submit button is submitForm(). I think the problem is in the PHP page. I've never done this type of value processing before, so... enough said :) :

Code: Select all

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?

$choice1;
$choice2;
$choice3;
$choiceCount1=0;
$choiceCount2=0;
$choiceCount3=0;


if($choice1){
	$choiceCount1 += 1;
	echo "$choiceCount1 counts for number 1";
}
elseif($choice2){
	$choiceCount2 += 1;
	echo "$choiceCount2 counts for number 2.";
}
elseif($choice3){
		$choiceCount3 += 1;
		echo "$choiceCount3 counts for number 3.";
}
else{
	echo "No values encountered.";
}
?>
</body>
</html>
I'm tryin to send the value of the radio button with a "http://blahblah/poll.php?choice=2" type code, so the PHP can see a choice variable has been attached to it (or sumthing...not sure yet) and then add to the variables that have been set up.

Any ideas? :D

Steve
User avatar
Dr Evil
Forum Contributor
Posts: 184
Joined: Wed Jan 14, 2004 9:56 am
Location: Switzerland

Post by Dr Evil »

What is your idea behind this:

Code: Select all

...

<?php
$choice1; 
$choice2; 
$choice3; 
...
?>
?
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

Just declaring without assigning.
Post Reply