Plz Help For Mailer Coding

Discussion in 'PHP' started by help_me, Jul 12, 2006.

  1. #1
    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);

    }

    ?>
     
    help_me, Jul 12, 2006 IP
  2. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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.
     
    clancey, Jul 12, 2006 IP
  3. mushroom

    mushroom Peon

    Messages:
    369
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    mushroom, Jul 12, 2006 IP