souki Posted December 5, 2007 Share Posted December 5, 2007 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'); ?> Quote Link to comment Share on other sites More sharing options...
Cep Posted December 5, 2007 Share Posted December 5, 2007 Where in your script is $email_message and $username being set? Quote Link to comment Share on other sites More sharing options...
souki Posted December 5, 2007 Author Share Posted December 5, 2007 hey , sorry i dont understand the question >.< , some people created a site for me, but the email system doesnt work, the script is on the contactus page Quote Link to comment Share on other sites More sharing options...
fanfavorite Posted December 5, 2007 Share Posted December 5, 2007 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'); ?> Quote Link to comment Share on other sites More sharing options...
souki Posted December 5, 2007 Author Share Posted December 5, 2007 hey thanks for trying, but that didnt work either T.T , anymore suggestions? ty! Quote Link to comment Share on other sites More sharing options...
revraz Posted December 5, 2007 Share Posted December 5, 2007 Try making it simple first. Remove all the variables you are sending and just do a basic email with a Hi as the $message. Quote Link to comment Share on other sites More sharing options...
souki Posted December 5, 2007 Author Share Posted December 5, 2007 hi revraz, ive tried that, still blank Quote Link to comment Share on other sites More sharing options...
fanfavorite Posted December 5, 2007 Share Posted December 5, 2007 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 Quote Link to comment Share on other sites More sharing options...
souki Posted December 5, 2007 Author Share Posted December 5, 2007 i tried this, but when i click enter, for the message to be sent, it just refreshes the page with the php code on the page alone, help please? Quote Link to comment Share on other sites More sharing options...
Cep Posted December 6, 2007 Share Posted December 6, 2007 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? Quote Link to comment Share on other sites More sharing options...
souki Posted December 6, 2007 Author Share Posted December 6, 2007 yes that seems to be the case, is that an issue? Quote Link to comment Share on other sites More sharing options...
fanfavorite Posted December 6, 2007 Share Posted December 6, 2007 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 ?> Quote Link to comment Share on other sites More sharing options...
Cep Posted December 6, 2007 Share Posted December 6, 2007 ROFL... Yes souki you need wrap all php code in php tags or else the code will not be interpreted as php code Please let us know how you get on. Quote Link to comment Share on other sites More sharing options...
souki Posted December 7, 2007 Author Share Posted December 7, 2007 hey , i think we are getting somewhere, but whenever i test it by sending a message, all i get it "this is a test message", how do i recieve what is actually written? thanks!, and also the subject also says "test". ty ! Quote Link to comment Share on other sites More sharing options...
Cep Posted December 7, 2007 Share Posted December 7, 2007 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. Quote Link to comment Share on other sites More sharing options...
souki Posted December 10, 2007 Author Share Posted December 10, 2007 sorry, i fell soo dumb, cep will you be able to contact me via MSN , and setup the script for me on the server please? ty! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.