Jump to content

Help with a Contact Us PHP script , ty!


souki

Recommended Posts

hey im trying to fix this PHP script, can you please help me, i recieve the email, but the message is blank, help please!

 

 

<?php

$email_address = "testemail@testemail.com";

$email_from = "system@testemail.com";

 

//change to the proper email address

 

$message = "Comments / Suggestions\n\nName: ". $user_name ."\nEmail: ". $email_address ."\n\nMessage:\n\n". $email_message;

mail($email_address, "Message from: " . $user_name ." - Comments / Suggestions", $message, "From: ". $email_from);

 

// echo "Thank you, <B>". $user_name . "</B> we have recieved your message and will contact you soon.";

 

header('Location: contact-us-thanks.htm');

?>

Link to comment
Share on other sites

Try adding the header information:

 

<?

$email_address = "testemail@testemail.com";

$email_from = "system@testemail.com";

 

//change to the proper email address

 

$message = "Comments / Suggestions\n\nName: ". $user_name ."\nEmail: ". $email_address ."\n\nMessage:\n\n". $email_message;

 

$header_info = "MIME-Version: 1.0\r\n";                

$header_info .= "Content-type: text/html; charset=iso-8859-1\r\n";                

$header_info .= "From: ".$email_from;

 

mail($email_address, "Message from: " . $user_name ." - Comments / Suggestions", $message, $header_info);

 

// echo "Thank you, <B>". $user_name . "</B> we have recieved your message and will contact you soon.";

 

header('Location: contact-us-thanks.htm');

?>

Link to comment
Share on other sites

Copy this exactly and just change the two email address.   

 

$msg_body = "This is just a test"; 

$header_info = "MIME-Version: 1.0\r\n";                

$header_info .= "Content-type: text/html; charset=iso-8859-1\r\n";                

$header_info .= "From: Test User<system@testemail.com>";

$subject = "Testing Email";

$recemail = "testemail@testemail.com";

               

if (mail($recemail, $subject, $msg_body, $header_info)) {

$message = "Your message has been sent.  We will contact you as soon as we can.";

}else{

      $message = "There was an error while processing your request.  Please contact us by phone if you see this error.";

}

 

echo $message

Link to comment
Share on other sites

Are you saying that your script outputted this to the web browser?

 

$msg_body = "This is just a test";           
$header_info = "MIME-Version: 1.0\r\n";                               
$header_info .= "Content-type: text/html; charset=iso-8859-1\r\n";                               
$header_info .= "From: Test User<system@testemail.com>";
$subject = "Testing Email";
$recemail = "testemail@testemail.com";            
                               
if (mail($recemail, $subject, $msg_body, $header_info)) {
   $message = "Your message has been sent.  We will contact you as soon as we can.";
}else{
          $message = "There was an error while processing your request.  Please contact us by phone if you see this error.";
}

echo $message

 

If that's the case, you did surround this in php tags and saved it to a webserver which has PHP4/5 running on it?

Link to comment
Share on other sites

lol ok, well you need to surround the PHP with <? and ?>

 

<?

$msg_body = "This is just a test";         

$header_info = "MIME-Version: 1.0\r\n";                             

$header_info .= "Content-type: text/html; charset=iso-8859-1\r\n";                             

$header_info .= "From: Test User<system@testemail.com>";

$subject = "Testing Email";

$recemail = "testemail@testemail.com";           

                             

if (mail($recemail, $subject, $msg_body, $header_info)) {

  $message = "Your message has been sent.  We will contact you as soon as we can.";

}else{

          $message = "There was an error while processing your request.  Please contact us by phone if you see this error.";

}

 

echo $message

?>

Link to comment
Share on other sites

I am failing to understand what you mean if you received the "this is a test message" then you have received the email from the code.

 

What you now need to do is customise the code and change the data within the variables $msg_body for the email body text, $subject to whatever title you want the email to be sent with and to thirdly change the header info for the FROM address to whatever you need.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.