Solved

using same form for add and edit in php

Posted on 2014-11-07
3
254 Views
Last Modified: 2014-11-17
Hi

I usually use the same form in php for add and edit. If the form is for add i leave the fields empty and change the button text to add. If the page if for edit i populate it with appropriate values from the database and change button text to update. There may be some other minor tweaks too. However I have been reading around and saw this

"http://stackoverflow.com/questions/6657331/add-view-edit-mysql-entries-with-the-same-php-form"

"It's generally quite easy to use the same form. Another question is how you solve validation errors and not making the user re-fill the form - this gets solved as in the same process. You'll need some helpers for the select fields and any checkbox/radio fields. Exactly how much the helpers do is up to you, but these will get you started:"

I dont know what this means. Why do i need helped? If the user changed a select or radio button on an edit then the form validation would pick it up wouldnt it if there was a problem

If there is a simple design pattern for using the same form for adds/updates I would be grateful if you could point me to it

thanks
0
Comment
Question by:andieje
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 250 total points
ID: 40429664
I often do it the way you do.  I would ignore that page from Stackoverflow, there is a lot missing from their code examples.
0
 
LVL 49

Expert Comment

by:PortletPaul
ID: 40429689
You also need to consider the quality measures of that page
it is 3 years old
There is no accepted answer
there are only 2 responses
there is only one upvote (in 3 years)

not all web pages are of a high quality :(
0
 
LVL 110

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
ID: 40429825
HTML Form processing is discussed here:
http://php.net/manual/en/tutorial.forms.php

There is no single, simple way to handle text inputs, radio buttons and check boxes.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_5450-Common-Sense-Examples-Using-Checkboxes-with-HTML-JavaScript-and-PHP.html

Table maintenance is a fairly advanced concept in PHP and MySQL.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_12335-PHP-and-MySQLi-Table-Maintenance.html

A sensible design pattern using MySQL might take advantage of the MySQL-only REPLACE INTO statement.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question