Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP script not returning data, please can you help

Status
Not open for further replies.

DougieMcN

Technical User
Sep 16, 2007
13
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 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).

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 script...
<?php

$to = 'me@myemailaddress.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);
?>

Actionscript code...
stop();

var fullName:TextField;
var fullAddress:TextField;
var postcode:TextField;
var telNumber:TextField;
var emailAddress:TextField;

fullName.restrict = "A-Za-zÁáÉéêíÍãõç ";
fullName.maxChars = 40;

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

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

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

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

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

myData.fullName = fullName.text;
myData.fullAddress = fullAddress.text;
myData.postcode = postcode.text;
myData.telNumber = telNumber.text;
myData.emailAddress = emailAddress.text;
}


this.submitButton.onRelease = function()
{
if (fullName.text == "" || fullAddress.text == "" || postcode.text == "" || telNumber.text == "")
{
gotoAndStop("error");
}

else

{
sendEmail();
gotoAndStop("correct");
}

myData.sendAndLoad("iopost.php", myData, "POST");
};

 
Code:
$sent = mail ($to, $subject, $message, "From: me@domain.com\r\n");

as one potential solution
 
Hi, thanks for the reply.

It looks as if my PHP scripts seems to be working (although I could be wrong being new to PHP) because when I point to it 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).

<?php
$to = 'me@myaddress.co.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);
?>

Thanks.
 
echo out the values of the global variables as a debug.

Code:
echo "<pre>";
echo "POST vars <br/>";
print_r($_POST);
echo "GET vars <br/>";
print_r($_GET);
echo "</pre>";

this will tell you whether the right values are even making it to the server.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top