By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,203 Members | 1,549 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,203 IT Pros & Developers. It's quick & easy.

PHP script not returning data, please can you help

P: 9
Hi, I've set up a form in flash which will send data to a PHP file on my web space, which in return will return the data from the textfields to my e-mail address. I know PHP is enabled in enabled on my web server because I tested it and it's OK.

Please can anyone check my PHP script below to see if I am missing something that would cause my e-mails not to be returned (I'm new to PHP).

I posted last week and I had to many parameters but I have now got them down to three so I hope that is OK so I am purely looking for the users input to be returned.

The PHP script is below (I've put the Actionscript code as well in-case someone notices something there)

I have tested this in an HTML page on my web server but no response from my form is received.

Thanks in advance.

PHP...
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $to = 'me@myemailaddress.co.uk';
  3. $subject = 'Request';
  4.  
  5. $message = '';
  6. $message .= "\n";
  7. $message .= "Name: $fullName";
  8. $message .= "\n\n";
  9. $message .=  "Address: $fullAddress";
  10. $message .= "\n\n";
  11. $message .= "Postcode: $postcode";
  12. $message .= "\n\n";
  13. $message .= "Tel: $telNumber";
  14. $message .= "\n\n";
  15. $message .= "E-mail: $emailAddress";
  16.  
  17. $sent = mail ($to, $subject, $message);
  18. ?>
  19.  
Actionscript...
Expand|Select|Wrap|Line Numbers
  1. stop();
  2.     var fullName:TextField;
  3.     var fullAddress:TextField;
  4.     var postcode:TextField;
  5.     var telNumber:TextField;
  6.     var emailAddress:TextField;
  7.  
  8. fullName.restrict = "A-Za-z ";
  9. fullName.maxChars = 40;
  10.  
  11. fullAddress.restrict = "0-9A-Za-z!?.+\- ";
  12. fullAddress.maxChars = 90;
  13.  
  14. postcode.restrict = "0-9A-Za-z!?.+\- ";
  15. postcode.maxChars = 10;
  16.  
  17. telNumber.restrict = "0-9A-Za-z!?.+\- ";
  18. telNumber.maxChars = 20;
  19.  
  20. emailAddress.restrict = "0-9A-Za-z!?.+\- ";
  21. emailAddress.maxChars = 50;
  22.  
  23. function sendEmail(fullName, fullAddress, postcode, telNumber, emailAddress)
  24. {    
  25.     var myData:LoadVars = new LoadVars();
  26.  
  27.     myData.fullName = fullName.text;
  28.     myData.fullAddress = fullAddress.text;
  29.     myData.postcode = postcode.text;
  30.     myData.telNumber = telNumber.text;
  31.     myData.emailAddress = emailAddress.text;
  32. }
  33.  
  34.     this.submitButton.onRelease = function()
  35.     {
  36.         if (fullName.text == "" || fullAddress.text == "" || postcode.text == "" || telNumber.text == "")
  37.     {
  38.         gotoAndStop("error");
  39.     }
  40.  
  41.     else
  42.  
  43.     {
  44.         sendEmail();
  45.         gotoAndStop("correct");
  46.     }
  47.  
  48.     myData.sendAndLoad("iopost.php", myData, "POST");    
  49. };
  50.  
Oct 19 '07 #1
Share this Question
Share on Google+
3 Replies


Atli
Expert 5K+
P: 5,058
Hi.

To use variables sent via the POST protocol in your PHP scripts, use the $_POST super-global.

Try something like:
Expand|Select|Wrap|Line Numbers
  1. $message = '';
  2. $message .= "\n";
  3. $message .= "Name: {$_POST['fullName']}";
  4. $message .= "\n\n";
  5. $message .=  "Address: {$_POST['fullAddress']}";
  6. # Etc...
  7.  
Oct 20 '07 #2

P: 9
Hi, thanks for the reply.

It looks as if my PHP script seems to be working now, thanks for the tip (although I could be wrong being new to PHP), but now when I point to the script in a browser window I get an e-mail sent to me but only the headings are there.

Name:
Address:
etc...

The information from the textfields in the SWF file are not being captured.

I think I may have to post in the flash section but thanks for your help, and the speedy reply.

I you feel this may still be a PHP problem please post any thoughts if you can and I'll keep a lookout for any info (I've put my latest script below just in-case).

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $to = 'me@myaddress.co.uk';
  3. $subject = 'Request';
  4.  
  5. $message = '';
  6. $message .= "\n";
  7. $message .= "Name: {$_POST['fullName']}";
  8. $message .= "\n\n";
  9. $message .=  "Address: {$_POST['fullAddress']}";
  10. $message .= "\n\n";
  11. $message .= "Postcode: {$_POST['postcode']}";
  12. $message .= "\n\n";
  13. $message .= "Tel: {$_POST['telNumber']}";
  14. $message .= "\n\n";
  15. $message .= "E-mail: {$_POST['emailAddress']}";
  16. $sent = mail ($to, $subject, $message);
  17. ?>
  18.  
Thanks.
Oct 20 '07 #3

Atli
Expert 5K+
P: 5,058
Hi again.

It's been a while since I've used Flash so I may be wrong here but...

You have an object, 'myData' defined inside a function 'sendEmail'. But you are using the object outside the scope of the 'sendEmail' function. I would have to guess that is the problem.

Try calling the 'sendAndLoad' method on the object inside the 'sendEmail' function.
Oct 23 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.