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 8813831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:57:28+00:00 2026-06-14T03:57:28+00:00

I am attempting to auto-generate a form based on information in a Mysql database.

  • 0

I am attempting to auto-generate a form based on information in a Mysql database. Right now, one table stores information about the fields that are needed – the field type, maxlength, default value, etc.

A second table contains html / php code for displaying the proper form input, based on information retrieved from the previously mentioned table. Neither of these tables include any user-inputed data. In order to process and display this stored code, I have been trying to use php’s eval function. Although I’m not sure this is a good solution, the only alternative I could think of was to have dozens of one or two line files which are retrieved by using php’s include or using jquery to append the contents. The main reason I didn’t want to do this was to avoid having the dozens of extra files.

Here is the eval statement that I have so far

eval("\$code=\"$field[input_code]\";");echo"<td>$code</td>";

Here is a sample of one of the contents of $field[‘input_code’]

<input name='".$field['form_name']."'type='text'placeholder='".ucwords(str_replace('_',' ',$field['form_name']))."'".if($field['req']==1){echo"class='textvalreq'required";}else{echo"class='textval'";}.">
  • 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-06-14T03:57:30+00:00Added an answer on June 14, 2026 at 3:57 am

    If $field['input_code'] contains an expression,

    eval("\$code=\"$field[input_code]\";");
    

    will not work as php would try to do sth. like:

    $code = "if (<condition>) { ... }";
    

    This would eventually end up as a valid string but if the variable contains quotes all hell will break loose.

    I’m sorry. I don’t see a trivial solution to the problem other than not storing arbitrary code in a database and trying to eval() it.

    Btw: eval() is evil.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to use resources to auto generate routes for my resource. The
I am attempting to use a custom workflow activity to auto-increment build numbers based
Using Java, I get this error when attempting to connect to a mysql database:
I'm attempting to implement a repository pattern with my poco objects auto generated from
I'm attempting to make an auto-indenting textarea and so far it works with the
I am attempting to pull data from the local database and display it in
I am attempting to post form data to my app using Facebook. My form
i'm attempting to create a table with an incremental ID. This isn't the simple
I'm attempting to write my first php/mysql page and am running into a SQL
I'm newish to NHibernate, and am attempting to wire up to a DB2 table

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.