i want to do mail to customer from database select but i am not successfully i write following code if any mistake in this code tell me <? $user_id = $_POST["userid"]; echo $user_id; exit; if($_POST) { mysql_connect("localhost","db_user","db_pass"); mysql_select_db("database"); echo $query = "select email_id from table1 where id = '".$_POST["userid"]."'"; $result = mysql_query($query); $row = mysql_fetch_array($result); $mail_to = $row["email_id "]; $body = $_POST["prd_sell"]; $phone_no =$_POST[" email"]; mail($mail_to,$mail_from ,$body); mail($mail_to,$mail_from, $body, $phone_no); } ?>
I tested this and I did not see a lot of problems. However, I have been having more luck using "mysql_fetch_object" than "mysql_fetch_array" With my method you would access the field by saying "$mail_to = $row->email_id" I also noticed that you have some spaces in the quoted variables. This is a problem unless the form names and mysql column names contain spaces.
Your " mail();" function may be incorrect. mail($to, $subject, $message, $headers); PHP: http://ca.php.net/manual/en/function.mail.php and http://ca.php.net/manual/en/ref.mail.php