Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6760499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:04:16+00:00 2026-05-26T14:04:16+00:00

I am working on an application that is used for managing the groups of

  • 0

I am working on an application that is used for managing the groups of recipients and multiple contents to send

I want to use different html design so i saved it in a table with some PHP code in it.

But problem is this, I m not getting the PHP code executed when send mail using these HTML contents.

I m using PHPMailer for sending mails and saved HTML contents using addslashes and getting back with stripslashes.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:04:17+00:00Added an answer on May 26, 2026 at 2:04 pm

    Saved HTML contents using addslashes and getting back with
    stripslashes.

    That’s bad. I don’t know why you did, but if your intention was to escape queries, use mysql_real_escape_string(), or an analgoue function for your DB driver (or use parametrized queries).
    If your intention was to, I don’t know, sanitize html? well, that’s useless. So no need to add slashes here for any reason.

    But problem is this, I m not getting the PHP code executed when send
    mail using these HTML contents.

    Because your content is returned as a string, so PHP will read it as such, tags included.

    A dirtiest solution, AND HIGHLY DISCOURAGED, is using eval() to evaluate php code and have it executed. But this is very risky and can lead to serious security problems, so I’m not even going to show you some example 🙂

    The BEST SOLUTION is to use some sort of templating system. I’m not suggesting using Smarty or another full-blown template engine, but you can roll-out a simple custom-code parser that can work along these lines:

    You save your variables using a placeholder, like

    {{variable_text}}  {{recipient}} {{address}}
    

    or something like this. The you just replace what you need, so in your PHP script that reads this e-mail you can do like

    $change = array('recipient' => 'John Smith',
                    'address' => 'Unknown Avenue, 666',
                    'variable_text' => 'We are glad to invite you to');
    
    $text = '<p>To: {{recipient}}.</p>
             <p>Address: {{address}}.</p>
             Message: Dear{{recipient}}<br />{{variable_text}}';
    foreach($change as $k => $v)
    {
       $text = str_replace('{{'.$k.'}}', $v, $text);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with an application that is used by multiple clients. Each client
I am working on an application that will be used as an extensible framework
I'm working on a Ruby on Rails application that used the Devise authentication system.
I'm working on a split view application that is used to view PDF files
I currently working on a application that use Entity Framework 4.1 (code first) and
I'm working on a .net application that will be used for auditing the configuration
I'm working on a java swing application that will be used in a psychology
I am working on an application that needs to use a local sql database.
I am working on an application that will be used by schools. Each school
I am working on an application that monitors phone use (specifically, what time its

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.