matt.sisto Posted March 30, 2009 Share Posted March 30, 2009 I have adapted the mail example from the php manual, but it must be wrong. If anyone can point out my mistakes I would really appreciate it. <?php require "dbconn2.php"; $email = $_POST['email']; $name = $_POST['name']; $body= $_POST['body']; $con_id =$_POST['con_id']; $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id'"; $result=mysql_query($sql); $to = $_GET['email_address']; $sender = $_GET['name']; $message = $_GET['body']; $from = $_GET['email']; if (mail($to, $sender, $message, $from) { header ("Location: message.php"); exit(); } else { header ("Location: index.php"); exit(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>?Message Consultant</title> </head> <body> </body> </html> Link to comment https://forums.phpfreaks.com/topic/151745-mail-script-not-working-any-help-appreciated/ Share on other sites More sharing options...
Ayon Posted March 30, 2009 Share Posted March 30, 2009 have you tried echo'ing out the values of your variables? Link to comment https://forums.phpfreaks.com/topic/151745-mail-script-not-working-any-help-appreciated/#findComment-796829 Share on other sites More sharing options...
premiso Posted March 30, 2009 Share Posted March 30, 2009 Which is it buddy? Post or get? Since I do not know which, I will take it you meant POST and not GET <?php require "dbconn2.php"; if (isset($_POST['con_id'])) { $from = $_POST['email']; $sender = $_POST['name']; $message = $_POST['body']; $con_id =$_POST['con_id']; $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id'"; $result=mysql_query($sql); $to = mysql_result($result, 0, 0); /* Redundant/not needed. $sender = $name; $message = $_GET['body']; $from = $_GET['email'];*/ if (mail($to, $sender, $message, $from) { header ("Location: message.php"); exit(); }else { header ("Location: index.php"); exit(); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>?Message Consultant</title> </head> <body> Error, no data was submitted. </body> </html> Made some comments and removed/modified the code. Let me know of any questions about it. Link to comment https://forums.phpfreaks.com/topic/151745-mail-script-not-working-any-help-appreciated/#findComment-796875 Share on other sites More sharing options...
matt.sisto Posted March 30, 2009 Author Share Posted March 30, 2009 Thanks Premiso and Ayon first of all for your help. Ayon before I added the mail script I was just echoing out the sql to make sure the right values were being passed from my form and I t worked so I am guessing it is just my mail script. Premiso I have tried what you suggested but it just returns a blank screen? do you have any further suggestions? Link to comment https://forums.phpfreaks.com/topic/151745-mail-script-not-working-any-help-appreciated/#findComment-797026 Share on other sites More sharing options...
matt.sisto Posted March 30, 2009 Author Share Posted March 30, 2009 Can anybody help? Link to comment https://forums.phpfreaks.com/topic/151745-mail-script-not-working-any-help-appreciated/#findComment-797077 Share on other sites More sharing options...
matt.sisto Posted March 30, 2009 Author Share Posted March 30, 2009 Does anybody have an idea as to why this code is not working and just displaying a blank page? <?php require "dbconn2.php"; if (isset($_POST['con_id'])) { $from = $_POST['email']; $sender = $_POST['name']; $message = $_POST['body']; $con_id =$_POST['con_id']; $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id'"; $result=mysql_query($sql); $to = mysql_result($result, 0, 0); /* Redundant/not needed. $sender = $name; $message = $_GET['body']; $from = $_GET['email'];*/ if (mail($to, $sender, $message, $from) { header ("Location: message.php"); exit(); }else { header ("Location: index.php"); exit(); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>?Message Consultant</title> </head> <body> Error, no data was submitted. </body> </html> appreciate any help. Link to comment https://forums.phpfreaks.com/topic/151745-mail-script-not-working-any-help-appreciated/#findComment-797166 Share on other sites More sharing options...
Ayon Posted March 31, 2009 Share Posted March 31, 2009 dunno if this is the reason... but i just noticed it... your missing a ) at the end there... if (mail($to, $sender, $message, $from) { Link to comment https://forums.phpfreaks.com/topic/151745-mail-script-not-working-any-help-appreciated/#findComment-797400 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.