Jump to content

Best way to reuse a form?


mazman13

Recommended Posts

I have a form that I have in the admin section of a site. This form is used for adding new companies to the database. I also have a drop down box below it showing all the companies currently in the db.

 

I want to use this page as an add/edit page. I want them to be able to click on a company in the drop down box and populate the form with the info from the drop down box so they can edit...but i also want to use the form from them to add info...

 

In the past I had two forms...one normal (for adding) and the another for editing field with php....but there has to be a better way than to call each form...

 

whats the best way?

Link to comment
https://forums.phpfreaks.com/topic/140806-best-way-to-reuse-a-form/
Share on other sites

Make the form in it's own php file, then for the names have a variable $addOrEdit then define this in the main script what the user is doing then in the form php file have that variable set in the right places and viola the form works for both.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.