Log in

View Full Version : PHP Auto Reply



kamelkis
09-13-2010, 11:48 PM
I am not getting an Auto reply sent back to the customer (person filling out the form) Any Ideas?

<?php
$contact_name = $_POST['name'];
$contact_email = $_POST['email'];
$contact_subject = $_POST['subject'];
$contact_message = $_POST['message'];

if( $contact_name == true )
{
$sender = $contact_email;
$receiver = "bkindustries@bkindustries.net";
$client_ip = $_SERVER['REMOTE_ADDR'];
$email_body = "Name: $contact_name \nEmail: $sender \n\nSubject: $contact_subject \n\nMessage: \n\n$contact_message \n\nIP: $client_ip \n\nContact Sent from http://www.bkindustries.net";
$extra = "From: $sender\r\n" . "Reply-To: $sender \r\n" . "X-Mailer: PHP/" . phpversion();

if( mail( $receiver, "BK Industries - $contact_subject", $email_body, $extra ) )
{
echo "success=yes";
}
else
{
echo "success=no";
}
}
?>

[Nicolas]
09-14-2010, 02:28 AM
Try something like AllForms, I love it.
http://allforms.mailjol.net
When making a form in the basic part, you have that option.

fileserverdirect
09-14-2010, 02:39 AM
At the end write:


else echo "no contact";

and see if it shows up

kamelkis
09-14-2010, 02:51 AM
Unless I am putting it in wrong that doesn't seem to fix itm any other ideas?

fileserverdirect
09-14-2010, 03:15 AM
It should not, it's a diagnostic tool, what does the page say when a form is submitted to it?

fastsol1
09-14-2010, 03:32 AM
$contact_name is not going to equal TRUE, it will equal what was entered in the form. If you are simply looking to make sure something has been entered in the name field then use this.

if (!empty($contact_name)

instead of this.

if( $contact_name == true )

kamelkis
09-14-2010, 05:12 AM
You can use the contact us form at bkindustries.net to see it work. It will send the message to me no problem, but it doesn't send the auto reply back to the person who filled out the form.

The if( $contact_name == true ) is simply checking if it has something there. If that part of the form is empty then it = false, if there is any content in it at all then it = true.

I will however try it your way to see if it allows the auto reply to send by some fluke, thank you.

Any other Ideas guys on what might be preventing it from sending? (The way I posted it is IDENTICAL to how it is on the server.

bluewalrus
09-14-2010, 05:28 AM
You didnt set it to send it back to the original person. The reply to only tells the recipient of the mail where to reply back to. Make another mail function that sends a message to the user as well...



$extra2 = "From: $receiver\r\n" . "Reply-To: $receiver \r\n";
if( mail( $receiver, "BK Industries - $contact_subject", $email_body, $extra) && mail( $sender, "Info Received", $email_body, $extra2 ) )
{