Thread: Echo PHP code

Page 2 of 2 First 12
  • Jump to page:
    #16
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2011
    Location
    Earth, Solar system
    Posts
    30
    Rep Power
    4

    Post


    Originally Posted by Triple_Nothing
    Aight. From what it is now sounding, your goal is VERY simple. I would use the switch() function with this. Build each file to be included as you wish for your form. Then, run something similar to this between your form tags to include the desired form:
    PHP Code:
    switch($_GET['type']) {
      case 
    "add":
        include(
    'file_add.php');
        break;
      case 
    "edit":
        include(
    'file_edit.php');
        break;
      case 
    "remove":
        include(
    'file_remove');
        break;

    And you mention you have a text file...and then mention a PHP file. You're not writing this in HTML files, are you? This is all to be done in a PHP file, otherwise PHP functions and variables do nothing since the server has zero clue it's PHP.
    Oh My! ... that's exactly what I wanted to do ... thanks a million

    Solved my problem..

    Cheers everyone for the help.
  2. #17
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2011
    Location
    Earth, Solar system
    Posts
    30
    Rep Power
    4

    Post


    PHP Code:
    switch($_GET['type']) { 
      case 
    "add"
        include(
    'file_add.php'); 
        break; 
      case 
    "edit"
        include(
    'file_edit.php'); 
        break; 
      case 
    "remove"
        include(
    'file_remove'); 
        break; 

    So this works beautifully in every sense.

    I was wondering thou, is it possible to have the content of the file_add.php file in a table in MySQL and read it from there instead of having the actual file in the server?

    Any thoughts on this?
  4. #18
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    189
    Rep Power
    0
    You seem to be spending an AWFUL lot of time and energy on something that is so unusual and so complex. What is keeping your from simply using the include statemnts? They don't have to be in your web tree so they are pretty secure. So whatever is the point??
  6. #19
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2011
    Location
    Earth, Solar system
    Posts
    30
    Rep Power
    4

    Post


    Originally Posted by jimmyg999
    You seem to be spending an AWFUL lot of time and energy on something that is so unusual and so complex. What is keeping your from simply using the include statemnts? They don't have to be in your web tree so they are pretty secure. So whatever is the point??
    I'll tell you what the point is.

    I ultimately want my application to be configurable easily by the end user with minimum amount of programming knowledge.

    As I mentioned earlier, I'll be having different types of documents and each document will be having different kind of form elements for the user to input the data. I already know all of the existing document types, so what you're saying is absolutely correct of the time being. But I know for fact that later on there will be more document types with different form elements. Now, with your approach, if I want to introduce the new document types to the application, I need to do some programming and configure myself (or a programmer) as I need design all of those form elements, create php files for them, store them in server and link them to the templates.

    But if I somehow can store the contents in db, and provide the user a facility to tell the system what fields are needed for the new document type, then all of this would be automatic. No programming needed, no file creation needed and at the end of the day the user himself (preferably the admin) logs into the system, tells it that there's a new document type, gives it a name, tell it that these specific fields are needed and the rest is taken care by the system.
  8. #20
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    189
    Rep Power
    0
    Did you ever hear of 'job security'?
  10. #21
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2011
    Location
    Earth, Solar system
    Posts
    30
    Rep Power
    4

    Post


    Originally Posted by jimmyg999
    Did you ever hear of 'job security'?
    yes. and I'm not worried about that. What's your point? speak your mind please.
  12. #22
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    189
    Rep Power
    0
    No point to be made. I heard your reasons and understand. I just thought it was quite an ambitious programming effort for someone whose php skills were not quite up to the task and had to question why you made the project so difficult for yourself.
  14. #23
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2011
    Location
    Earth, Solar system
    Posts
    30
    Rep Power
    4

    Post


    Originally Posted by jimmyg999
    No point to be made. I heard your reasons and understand. I just thought it was quite an ambitious programming effort for someone whose php skills were not quite up to the task and had to question why you made the project so difficult for yourself.
    That's right actually. I'm new in PHP and I'm learning it on my own. It's quite going good to be honest, thanks to online sources and people like you who like to help others.

    The project that I'm working on is indeed complex and large but that doesn't mean it's impossible to achieve. and I think (and surely hope) the final result would be satisfying.

    Cheers for being honest and speaking what's on your mind
  16. #24
  17. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    677
    Rep Power
    7
    Yes, a table or such can be built from a MySQL db. You do not need to include files, n can just place the code that WOULD be in those files in place of the include(). It just keeps it cleaner this way if you had larger forms.

    As far as building your forms from DB, how? Is it physically the same form, just filled with different data on load? Or is it really completely different forms? If totally different, a DB is so NOT the way to go for such. It is just to cataloge data, not scripting.
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo