;

PDA

Click to See Complete Forum and Search --> : loadVariablesNum --> PHP help needed!


Josamoto
04-06-2006, 04:50 PM
I'm not getting too much help in the Actionscript forum on this topic:

http://www.flashkit.com/board/showthread.php?t=681568

Maybe someone more in Koolmoves can help. Just trying to send some variables from my Actionscript to PHP.

blanius
04-06-2006, 05:52 PM
what is loadVariablesNum? try dropping the Num part.

Josamoto
04-06-2006, 06:15 PM
Just tried it, as I read in another thread that KM doesn't support loadVariablesNum. Or at least it didn't work in some version.

I've added the .fun and .php file again, maybe that will help a bit.

You'll notice most variables are hard coded in the PHP script at the moment, I'll move on when the Subject works along nicely.

I desperately need this script to work. It's the final component I need for my website.

blanius
04-06-2006, 07:40 PM
loadVariables("sendmail.php","POST")

Chris_Seahorn
04-06-2006, 07:58 PM
Solved below..........

Josamoto
04-06-2006, 07:58 PM
Is this clause correct in the PHP file:
$Subject = $_POST['Subject'];

As I understand, this is supposed to fetch the variable "Subject" from my AS.

Tried loadVariables("sendmail.php","POST"), it does nothing at all now.

Chris_Seahorn
04-06-2006, 08:20 PM
This was tested OK. I have it write the POST variables to text so I could test locally without actually firing the mail. Just drop the text writing from the PHP once you have your routine where you want it.

<?php
$ToName = "Josef van Niekerk";
$ToEmail = "...@...";

$FromName = "Mr.T";
$FromEmail = "...@...";

$Subject = $_POST['mysubject'];
$Message = "This is only a test!!! :)";

mail("$ToName <$ToEmail>", "$Subject", "$Message", "From: $FromName<$FromEmail>");

//this section writes a text file to confirm variables sent..remove if not needed
$test ="$ToName <$ToEmail>";
$test .="$Subject";
$test .="$Message";
$test .="From: $FromName<$FromEmail>";
$file= fopen("testmail.txt", "w");

fwrite($file, $test);
fclose($file);

?>

Attachment of FUN file below. You should really try to get yourself using the loadVars class. It's a lot more flexible.

Josamoto
04-06-2006, 08:40 PM
IT WORKED! Thanks, dude! That's so awesome!

Josamoto
04-06-2006, 08:44 PM
Why wouldn't it work with a hidden variable, without the dynamic text field?

Josamoto
04-06-2006, 08:46 PM
No worries!

With or without the dynamic text field, your code is working perfectly. I cannot thank you enough for your help!

Chris_Seahorn
04-06-2006, 08:48 PM
It would. I just used the textfield out of habit since that was the only actual POST variable. You could declare it and then POST it.

Josamoto
04-06-2006, 09:05 PM
I notice that when my variables inside the PHP script, for ex. mysubject has any capitals in it, it fails to work.
Use
$Subject = $_POST['mysubject'];
and not
$Subject = $_POST['mySubject'];
is this PHP convention?

Also, how do I remove the \ slashes before some special characters?

Chris_Seahorn
04-06-2006, 09:09 PM
Well....Subject I've always treated as a reserved word. Notice I used "mysubject".

To strip slashes or add slashes in a posted variable you could use:

$Subject = stripslashes($_POST['mysubject']);
$Subject = addslashes($_POST['mysubject']);

Josamoto
04-06-2006, 09:11 PM
Thanks, got stripslashes working. And Subject being a reserved word, I'm not suprised. Why didn't I think of that from the start.

Thanks again for your help!

Chris_Seahorn
04-06-2006, 09:16 PM
No sweat man. In your free time check out the loadVars class. It is much cooler , more flexible and is perfect when the response from your PHP file is needed in instances of confirmation or similar.

Anyway I can help...stop by the site.