PHP script not returning data, please can you help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DMcN
    New Member
    • Oct 2007
    • 9

    PHP script not returning data, please can you help

    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...
    [CODE=php]
    <?php
    $to = 'me@myemailaddr ess.co.uk';
    $subject = 'Request';

    $message = '';
    $message .= "\n";
    $message .= "Name: $fullName";
    $message .= "\n\n";
    $message .= "Address: $fullAddress";
    $message .= "\n\n";
    $message .= "Postcode: $postcode";
    $message .= "\n\n";
    $message .= "Tel: $telNumber";
    $message .= "\n\n";
    $message .= "E-mail: $emailAddress";

    $sent = mail ($to, $subject, $message);
    ?>
    [/CODE]

    Actionscript...
    [CODE=actionscri pt]
    stop();
    var fullName:TextFi eld;
    var fullAddress:Tex tField;
    var postcode:TextFi eld;
    var telNumber:TextF ield;
    var emailAddress:Te xtField;

    fullName.restri ct = "A-Za-zÁáÉéêíÍãõç ";
    fullName.maxCha rs = 40;

    fullAddress.res trict = "0-9A-Za-zÁáÉéêíÍãõç!?.+ \- ";
    fullAddress.max Chars = 90;

    postcode.restri ct = "0-9A-Za-zÁáÉéêíÍãõç!?.+ \- ";
    postcode.maxCha rs = 10;

    telNumber.restr ict = "0-9A-Za-zÁáÉéêíÍãõç!?.+ \- ";
    telNumber.maxCh ars = 20;

    emailAddress.re strict = "0-9A-Za-zÁáÉéêíÍãõç!?.+ \- ";
    emailAddress.ma xChars = 50;

    function sendEmail(fullN ame, fullAddress, postcode, telNumber, emailAddress)
    {
    var myData:LoadVars = new LoadVars();

    myData.fullName = fullName.text;
    myData.fullAddr ess = fullAddress.tex t;
    myData.postcode = postcode.text;
    myData.telNumbe r = telNumber.text;
    myData.emailAdd ress = emailAddress.te xt;
    }

    this.submitButt on.onRelease = function()
    {
    if (fullName.text == "" || fullAddress.tex t == "" || postcode.text == "" || telNumber.text == "")
    {
    gotoAndStop("er ror");
    }

    else

    {
    sendEmail();
    gotoAndStop("co rrect");
    }

    myData.sendAndL oad("iopost.php ", myData, "POST");
    };
    [/CODE]
    Last edited by Atli; Oct 20 '07, 01:35 AM. Reason: Changed [code] tags to [code=php] and [code=actionscript] tags.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

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

    Try something like:
    [CODE=php]
    $message = '';
    $message .= "\n";
    $message .= "Name: {$_POST['fullName']}";
    $message .= "\n\n";
    $message .= "Address: {$_POST['fullAddress']}";
    # Etc...
    [/CODE]

    Comment

    • DMcN
      New Member
      • Oct 2007
      • 9

      #3
      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).

      [CODE=PHP]
      <?php
      $to = 'me@myaddress.c o.uk';
      $subject = 'Request';

      $message = '';
      $message .= "\n";
      $message .= "Name: {$_POST['fullName']}";
      $message .= "\n\n";
      $message .= "Address: {$_POST['fullAddress']}";
      $message .= "\n\n";
      $message .= "Postcode: {$_POST['postcode']}";
      $message .= "\n\n";
      $message .= "Tel: {$_POST['telNumber']}";
      $message .= "\n\n";
      $message .= "E-mail: {$_POST['emailAddress']}";
      $sent = mail ($to, $subject, $message);
      ?>
      [/CODE]

      Thanks.
      Last edited by Atli; Oct 23 '07, 12:12 AM. Reason: Fixed closing [/code] tags.

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        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.

        Comment

        Working...