PDA

View Full Version : Help, Found answer in BlueHost Support Center but still not working (php email form)



frequency
10-14-2006, 10:42 PM
Hello,

I have spend about 7 hours trying to get a very simple email form to display the "From" address when I recieve and email form my flash website / php form.

The form send the email, I get it, but it says <somethingwierd>@40.bluehost.com instead of the email that the person entered in the form.

I know this is simple, but I even spent 2 hours with Bluehost support and we ended up getting disconnected.

Here is my issue in the helpdesk:

http://helpdesk.bluehost.com/kb/index.php?x=&mod_id=2&id=231

in the flash (remember, the emails are sending, just not picking up the proper From address):
submit_btn.onRelease = sendMessage;

function checkForm():Boolean {
// this checks whether required fields have been filled in
// initialize missing flag on assumption everything OK
var missing:Boolean = false;
// if missing is true, return false
// otherwise return true
return missing ? false : true;
}
function sendMessage():Void {
// check whether form has been correctly filled in
var formOK:Boolean = true;
// if no problems, process the form and send variables to PHP script
if (formOK) {
// Form processing goes here
message.from = name_txt.text;
message.email = email_txt.text;
message.comments = comments_txt.text;
message.sendAndLoad("feedback.php?ck="+ new Date().getTime(), messageSent);
// display message informing user that email is being sent
}
}
// create LoadVars instance to retrieve date from PHP script
// initialize LoadVars to send form data
// and receive response from the PHP script
var message:LoadVars = new LoadVars();
var messageSent:LoadVars = new LoadVars();
// load date from PHP
messageSent.onLoad = function() {
if (this.sent == "OK") {
_parent.gotoAndStop(7);
} else {
comments.text = "Error calling PHP File!";
}
};



On the Buttons (may not be important)
name_txt
email_txt
comments_txt


feedback.php file:
<?php
// initialize variables for To and Subject fields
################################################
# Replace 'david@example.com' with the address #
# you want the feedback to be sent to #
################################################
$to = 'mahdi@lienreports.com';
$subject = 'Nationwide Vanlines Contact';

// build message body from variables received in the POST array
$message .= 'From: '.$_POST['from']."\n\n";
$message .= 'Email: '.$_POST['email']."\n\n";
$message .= 'Comments: '.$_POST['comments'];

// add additional email headers for more user-friendly reply
##################################################
# Replace 'Flash feedback<feedback@example.com>' #
# with an appropriate address for your website #
##################################################
$additionalHeaders = "Reply-To: ".$_POST[email]."\n";

// send email message
$OK = mail($to, $subject, $message, $additionalHeaders);
// let Flash know what the result was
if ($OK) {
echo 'sent=OK';
}
else {
echo 'sent=failed&reason='. urlencode('There seems to be a problem with the server. Please try later.');
}
?>

php.ini file:
Line 317: [mail function]
Line 318: SMTP = localhost
Line 319: sendmail_from = mahdi@lienreports.com
Line 320: sendmail_path = /usr/sbin/sendmail -t -i

Thank you.

Pethens
10-15-2006, 12:15 PM
frequency,

It looks like your PHP script is not setting a "From" header. See this thread for sample code:

http://www.bluehostforum.com/showthread.php?t=2712


Stephen