PDA

View Full Version : The mother of all problems


jimw00d
01-29-2003, 08:56 AM
I have a range of problems, I'll need to discuss some with a professional head doctor but my current flash mx problems surround the use of a mail form and php.

1 The method of clearing the selections of check boxes clears the check but not the value assigned by the user selection. One completed mail form retains the check box values of a previous one, even though the checks were removed by what I thought was an all encompassing setValue(false) command.

2 The php code generates an email for my inbox, fine. But I can't get the value of the if statement in php back into flash to let the user know if the mail was sent. I have used:

<html>
<?

$To= "northls@nbkayaking.com";

$ToSubject = "Enquiry";

$UserInfo= $HTTP_USER_AGENT."\n".$HTTP_ACCEPt."\n\n".$REMOTE_ADDR."\n\n".$Date= date("d/F/y\n\nH.i");

$EmailBody = "Sent By: $Name\nSenders Email: $Email\n\nFrom: $From\n\nInterested In: $InterestedIn\n\nMessage Sent:\n$Details\n\n$UserInfo";

$sendMail=mail($Name." <".$To.">",$ToSubject, $EmailBody, "From: ".$Name." <".$Email.">");

if (!$sendMail){
$status="Mail was not Sent";
}
else{
$status="Mail was Sent";
}
echo "&flashstatus=$status";
?>
</html>

"Mail sent" or not is the value I need to assign a dynamix t box in flash.

I have tried using loadVars and GET methods, without luck,

Would I need to get the value through a MC and then get the value of the php generated flash variable through the Mc.

I really have backed myself into a corner on this one.

That's it for now, any help would be cosmic

Regards

freddycodes
01-29-2003, 04:42 PM
Where is a excerpt from your actionscript. Did you use sendAndLoad or just load.


myVars = new LoadVars();
//Assign values from the form to the loadvars object
myVars.name = name.text;
myVars.email = email.text;
myVars.sendAndLoad("yourphpscript.php", this, "POST");
myVars.onLoad = function() {
dynTextBox.text = this.status;
}

jimw00d
01-29-2003, 08:50 PM
I am rebuilding the form from scratch there are two many bugs at the moment and I can't isolate them.

I think your code is the most constructive I have had and having read into the subject a little more I am beginning to understand how everything fits together.

If I may come back to you in a few days when I have the mail form done then that would be great.

How are you with php, could you see any errors etc.

Thanks for the code again.

Regards

freddycodes
01-29-2003, 09:39 PM
Very good with PHP. I don't see any apparent errors, but you should be able to test the functionality of the PHP script by har coding some values in. That would help to make sure that the script is working.

jimw00d
01-30-2003, 08:27 AM
OK, so last night I spent a few hours on the mail form and I have got it to the stage that I was last at.

In using your code to send and load a few questions have arisen.

I have used both a list box and check boxes, would:

myVars.country = listboxvariable.component;
myVars.interest = checkboxvariable.component;

work, or could the component part be left out. Am I being dumb in assuming that because you used for example name.text that you need to use .component also.

list and checkbox variables have been used to capture the values of the selection in each component.

One problem that I had when testing the php with the flash file locally using an apache localhost server set-up was that the function to post was in fact opening up the php file and displaying the result of the if condition. I wanted to avoid this. It may only be caused by apache configuration.

Thanks

freddycodes
01-30-2003, 05:05 PM
.text refers to the text associated with a text field whose instance name is what is behind the . so if you had a textfield named emailBox Then to access to the text in that textfield you would refer to it as emailBox.text

As for listboxes and checkboxes they work differently. Its all laid out in the reference for Flash MX. You should really take a gander in there.


List box would be

listboxvariable.getSelectedItem().data


Or if you didn't supply both data and labels for the list box

listboxvariable.getSelectedItem().label


Checkboxes work like

checkboxvariable.getValue()



Here I put this together, it should help you understand a little better.
http://www.irq11.com/~louie/mx.zip

jimw00d
01-30-2003, 05:19 PM
I have already used both getValue() and getSelectedItem() for each respective component and established variables to get the values.

My question was about the point of using .text and whether .value or .component needed to be used to additionally address the selected items in the way that .text is used to identify the text in a text field.

It seems that the script works even if .text is omitted. Is it used as a safeguard therefore.

for example the text in a dyn text field with the variable name infobox could be captured in the LoadVars using:

myVars.info = infobox;

Would this work??

Am I right in thinking that the variable info and not infobox would be passed to php?

Thankfou very much nevertheless for your sample.

Also using my php is it status or flashstatus that I need to target??

I've checked your sample, very nice, the response received was:

Received Response
$status";

?>

This might be because I am still at work and I don't have php on my laptop.

I assume it should display mail sent or not sent??
Best Regards