Storing email templates in mysql with php

Discussion in 'PHP' started by Agent_Smith, May 25, 2008.

  1. #1
    Hello,

    Im currently trying to insert email templates into mysql (does fine) but then using them to send a email.

    So, in my database i have:

    My basic php code to send this email:

    $query = "SELECT * FROM multi_emails WHERE id = '1'";
    $result = mysql_query($query) or die(mysql_error());
    $row = mysql_fetch_array($result);
    
    $system_email = "matt@blah.com";
    
    $headers = "From: $system_email\r\n";
    $headers .= "Reply-To: $system_email\r\n";
    $headers .= "Return-Path: $system_email\r\n";
    
    mail($email,$row['subject'],$row['message'],$headers);
    PHP:
    When the email is sent, it doesn't substitute the variables in, rather i get sent $password instead of my password.

    Any ideas?
    Thanks
     
    Agent_Smith, May 25, 2008 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    oh i guess u need register global on in php.ini

    Regards

    Alex
     
    kmap, May 25, 2008 IP
  3. Agent_Smith

    Agent_Smith Well-Known Member

    Messages:
    890
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    145
    #3
    Register globals are turned on. Does the same!

    Thanks!
     
    Agent_Smith, May 25, 2008 IP
  4. itnashvilleCOM

    itnashvilleCOM Banned

    Messages:
    176
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Register Globals are the worst security risk you can have...well at least top 3.

    Instead, do something like this for example:


    
    $sitename = 'boo.com';
    $email = '
    	Thank you for coming to %mysite%!
    ';
    
    $email = str_replace('%mysite%',$sitename,$email);
    
    PHP:
    That will replacce %sitename% with the site name, for example.

    register globals = BAD :mad:

    RG will also be totally removed from PHP6.
     
    itnashvilleCOM, May 25, 2008 IP