Why isn't the variable taken as a variable?



  • There's a website where the mail application sends a check letter with a type reference. approve.php?order_id=&email=

    There was a need to edit the text of the letter. To this end, a record has been created in the OBD system where the full text of the letter is kept.

    Letter:

    $mailSMTP = new SendMailSmtpClass($email_from, $email_password, $smtp_host, $email_from_name, $smtp_port);
    $entry_mail_result = $mailSMTP->send($email, $approve_theme, $approve_message, $headers);
    

    $approve_message Received from the database:

    <html>
     <a href=http://***/approve.php?id=$order_id&e=$email>Подтвердите</a>...
    </html>
    

    The letter contains two variables $order_id and $email♪ Both are initialized in the php file before sending a letter (the largest first code).

    But in a letter, $order_id and $email these values are not subtracted. Please tell me what's wrong?



  • The mistake (?) is that a text line comes from the OBD. It doesn't matter if there's something similar to the PHP variables, it doesn't analyze the code.

    OptionYou can use http://php.net/manual/ru/function.sprintf.php ♪ In the database, let them keep a label of letters where they're in the right place. %s for the insertion of text values and %d I don't know what you're talking about. For example,

    <html>
     <a href=http://***/approve.php?id=%d&e=%s>Подтвердите</a>...
    </html>
    

    Then function. http://php.net/manual/ru/function.sprintf.php The necessary values can be set:

    sprintf( $template_from_DB, $order_id, $email)
    // возвращает строку, где всё подставлено – можно отправлять.
    

    OptionHow professional postal services do, pump, mailChimp. There's a point where the fields being served are bigger. The text / the code of the letter puts its very special theater, so you might have had it. %ORDER_ID% and %EMAIL%:

    <html>
     <a href=http://***/approve.php?id=%ORDER_ID%&e=%EMAIL%>Подтвердите</a>...
    </html>
    

    After that, it's just going to change all these substrates to the right values:

    $approve_message = $tmpl; // $tmpl - прочитанный из базы макет письма 
    $approve_message = str_replace( '%ORDER_ID%', $order_id, $approve_message);
    $approve_message = str_replace( '%EMAIL%', $email, $approve_message);
    // теперь можно отправлять $approve_message
    

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2