View Full Version : Php and components
desertstream
03-24-2004, 09:42 PM
I am back again, now trying the php route. I have set up an email script in php according to the tute on this site. But, I still can't get the thing to pass the values of check box and radio button components from Flash into the email. Any thoughts?
This is the php that I have set up where the get value() did not work:
<?
$ToEmail = "webmaster@experiencevellano.com";
$ToName = "WebMaster";
$ToSubject = "Vellano Web Interest Form";
$EmailBody = "First Name: $first\nLast Name: $last\nSpouse Name: $spouse\nPhone Number: $tphone\nEmail: $emailadd\nStreet Address: $street\nCity: $ci\nState: $st\nZip Code: $zp\nCountry: $count\nSender Refered By: $refer\n600's and up: $six.getValue()\n900's and up:$nine.getValue()";
$EmailFooter="\nThis message was sent by: $first $last from $REMOTE_ADDR If you feel that you recieved this e-mail by accident please contact us at www.experiencevellano.com";
$Message = $EmailBody.$EmailFooter;
mail($ToName." <".$ToEmail.">",$ToSubject, $Message, "From: ".$first. $last." <".$emailadd.">");
Print "EmailStatus=Complete - Your mail has been sent";
?>
Thanks
Jason
splict
03-24-2004, 10:04 PM
.getValue() is a flash function, not a php function. you should be using .getValue in Flash MX or .selected in 2004. in (current versions of) php you should use $_GET['nine'] or $_POST['nine'] depending on the method you sent it with from flash. There are an enormous amount of threads on this forum that discuss/explain this and have code you could look at.
-splict
desertstream
03-24-2004, 10:22 PM
I am using the post method as shown below,
loadVariablesNum("vellanomail.php", "0", "POST");
I tried the post method on the checkboxes as suggested (checkboxes are named six and nine):
n600's and up:$_POST['six']\n900's and up:$_POST['nine']
And it did not work. Should the checkboxes have something done to the Change Handler section?
I am not experienced at all with PHP, this is my first stab at it thanks to the tutorials on this site. So, do I have one little something out of place?
Thanks for the help
splict
03-24-2004, 10:30 PM
if you are using MX or MX2004 then use LoadVars instead of loadVariablesNum. what version are you using?
Also, are you using .getValue or .selected inside Flash like I suggested? post more of your actionscript, or check some of the threads that deal with this - that way you could directly compare your code with them and see what you are doing wrong. I can try to help with loadVariablesNum but I haven't really used it - I use LoadVars() - so I don't know it as well.
-splict
desertstream
03-25-2004, 10:44 PM
I tried it by substituting LoadVars for LoadVariablesNum and it did not work. I am not sure that I was supposed to just siwtch the two evenly without changing anything else. As far as the .getValue (I am using MX), I don't know where that should go. All I have for action script, is calling the php file from the submit button as follows:
on (release) {
if (!Email.length || Email.indexOf("@") == -1 || Email.indexOf(".") == -1) {
EmailStatus = "Please enter a valid E-mail address";
} else if (!FirstName.length) {
EmailStatus = "Please Enter your name before Sending";
} else if (!LastName.length) {
EmailStatus = "Please Enter your last name before Sending";
} else {
loadVariablesNum("vellanomail.php", "0", "POST");
EmailStatus = "Your message is being sent...";
}
}
And then the PHP file is as follows:
<?
$ToEmail = "webmaster@experiencevellano.com";
$ToName = "WebMaster";
$ToSubject = "Vellano Web Interest Form";
$EmailBody = "First Name: $first\nLast Name: $last\nSpouse Name: $spouse\nPhone Number: $tphone\nEmail: $emailadd\nStreet Address: $street\nCity: $ci\nState: $st\nZip Code: $zp\nCountry: $count\nSender Refered By: $refer\n";
$EmailFooter="\n\nThis message was sent by: $first $last from $REMOTE_ADDR If you feel that you recieved this e-mail by accident please contact us at www.experiencevellano.com";
$Message = $EmailBody.$EmailFooter;
mail($ToName." <".$ToEmail.">",$ToSubject, $Message, "From: ".$first . " " . $last." <".$emailadd.">");
Print "EmailStatus=Thank You for your interest in Vellano";
?>
All of the text fields pass fine, but the check boxes and radio buttons I have yet to figure out how to code. Thanks.
Jason
splict
03-26-2004, 10:02 AM
You can't just switch them, they work differently. The manual explains how to use it (LoadVars) with a good exaple, I think. Also, there are a lot of posts about it (just search for LoadVars). Here is an example. Keep in mind LoadVars only sends the variables in your LoadVars object as oppossed to LoadVariableNum which sends all the variables in that clip. Because of this you need to assign all of your variables to your LoadVars object. In the following, I show one example with a textfield's variable and one with a checkbox. You will need to repeat these lines for all of the variables you want to send.
-splicton (release) {
if (!Email.length || Email.indexOf("@") == -1 || Email.indexOf(".") == -1) {
EmailStatus = "Please enter a valid E-mail address";
} else if (!FirstName.length) {
EmailStatus = "Please Enter your name before Sending";
} else if (!LastName.length) {
EmailStatus = "Please Enter your last name before Sending";
} else {
EmailStatus = "Your message is being sent...";
var mail_lv = new LoadVars();
// for all your text variables you want to send:
mail_lv.FirstName = FirstName;
// for all your check boxes:
mail_lv.six = six.getValue();
mail_lv.sendAndLoad("vellanomail.php", mail_lv, "POST");
}
}
desertstream
03-26-2004, 11:05 AM
Do I use the Instance Names for each field or the Var Name? I am assuming the Var Name. Also, do I need to change the php code for this? Is the php where I now use $POST_six? Sorry for all of the inexperience, I am trying to learn and I appreciate your help soooooo much!
Jason
splict
03-26-2004, 11:25 AM
The way I showed uses variable names. Preferable to that method (I didn't want to hit you with too much at once ;) ) is using an instance name for your textfield. In that case you would:// replace:
mail_lv.FirstName = FirstName;
// with
mail_lv.FirstName = FirstNameInstance.text;
// where 'FirstNameInstance' is the instance name of your textfield
The format in php for POST would be $_POST['six'] please read about it here (http://php.net/manual/en/reserved.variables.php#reserved.variables.post).
This pulls your variables out of your post array (which is sent by flash). There is something called register globals which, when enabled, allows you to refer to $_POST['six'] by merely $six. This is okay, but it is better to explicitly say where you want to get the variable from (in our case, the post array) because $six could refer to a variable $six you made in the file or even $_GET['six']. If you will be using it more that once or it makes it easier for you, you could always assign $_POST['six'] to $six:$six = $_POST['six'];
// or only do it if $_POST['six'] exists:
if (isset($_POST['six']) $six = $_POST['six'];
-splict
desertstream
03-26-2004, 03:16 PM
I am trying to put the value of six in the email body and when I add that code to the php as well as to the flash, it breaks down. Up until the addition of that with just the text it sent the email (although the php did not print back the status message as it did before), but now after adding the code for the checkbox, six, it doesn't send the email.
Actionscript:
on (release) {
if (!Email.length || Email.indexOf("@") == -1 || Email.indexOf(".") == -1) {
EmailStatus = "Please enter a valid E-mail address";
} else if (!FirstName.length) {
EmailStatus = "Please Enter your name before Sending";
} else if (!LastName.length) {
EmailStatus = "Please Enter your last name before Sending";
} else {
EmailStatus = "Your message is being sent...";
var mail_lv = new LoadVars();
// for all your text variables you want to send:
mail_lv.FirstName = FirstName.text;
mail_lv.LastName = LastName.text;
mail_lv.SpouseName = SpouseName.text;
mail_lv.Email = Email.text;
mail_lv.Address = Address.text;
mail_lv.City = City.text;
mail_lv.State = State.text;
mail_lv.Zip = Zip.text;
mail_lv.Country = Country.text;
mail_lv.Referral = Referral.text;
mail_lv.BrokerName = BrokerName.text;
mail_lv.six = six.getValue();
mail_lv.sendAndLoad("vellanomail.php", mail_lv, "POST");
}
}
PHP code:
<?
$ToEmail = "webmaster@experiencevellano.com";
$ToName = "WebMaster";
$ToSubject = "Vellano Web Interest Form";
$EmailBody = "First Name: $FirstName\nLast Name: $LastName\nSpouse Name: $SpouseName\nEmail: $Email\nAddress: $Address\nCity: $City\nState: $State\nZip: $Zip\nCountry: $Country\nReferral: $Referral\nBroker Name: $BrokerName\nSix: $six = $_POST['six']";
$EmailFooter="\n\nThis message was sent by: $first $last from $REMOTE_ADDR If you feel that you recieved this e-mail by accident please contact us at www.experiencevellano.com";
$Message = $EmailBody.$EmailFooter;
mail($ToName." <".$ToEmail.">",$ToSubject, $Message, "From: ".$FirstName . " " . $LastName." <".$Email.">");
Print "EmailStatus=Thank You for your interest in Vellano";
?>
splict
03-26-2004, 03:30 PM
I suggest getting everything working before you try to switch to the use of $_POST. so intead you can just use $six like you had it. but later, this is how you would do it. you want to assign $_POST['six'] (and any other post variables) to your $six and then use it. So your code would be:<?
$ToEmail = "webmaster@experiencevellano.com";
$ToName = "WebMaster";
$ToSubject = "Vellano Web Interest Form";
// this is the only line you would add (for each variable)
// it just makes sure that the value of $six was taken from the $_POST array
$six = $_POST['six']; // now we can just use $six to refer to what was in $_POST['six']
$EmailBody = "First Name: $FirstName\nLast Name: $LastName\nSpouse Name: $SpouseName\nEmail: $Email\nAddress: $Address\nCity: $City\nState: $State\nZip: $Zip\nCountry: $Country\nReferral: $Referral\nBroker Name: $BrokerName\nSix: $six";
// <- we just need to refer to $six now
$EmailFooter="\n\nThis message was sent by: $first $last from $REMOTE_ADDR If you feel that you recieved this e-mail by accident please contact us at www.experiencevellano.com";
$Message = $EmailBody.$EmailFooter;
mail($ToName." <".$ToEmail.">",$ToSubject, $Message, "From: ".$FirstName . " " . $LastName." <".$Email.">");
Print "EmailStatus=Thank You for your interest in Vellano";
?>
desertstream
03-26-2004, 04:27 PM
OK, so now that the checkboxes work, I am back to my original question for the forum, how do I get the radio buttons to work? I tried setting them up the same as the check boxes to no avail. Do I need to create a group of the radio buttons to find which one is selected? Should they be in a separate movie clip and then getValue of the movie clip?
Jason
splict
03-26-2004, 04:39 PM
Do I need to create a group of the radio buttons to find which one is selected?
correct. My first result for FlashMX radio and getValue via google (http://google.com) gave me the following which shows documentation on it: http://virusek.sgh.waw.pl/flash/flashMX/html/30_asd_05_f90.html
I can't tell you exactly where/what the setting is, because I am using 2004, but I am sure there is something along the lines of groupName in the parameters for the component instance.
-splict
Ducyman
02-21-2005, 11:07 PM
Hi there,
I've read your posts and made the same changes to my files. The program works fine. but i cannot see that the email is send succesfull. normally you get in de emailstatus window: Thanks for you email. I think my problem is that my form is on layer 6 and not on 0. How can I specify this
Hopefully you understand. my english is not so well.
Ciao Ducyman
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.