Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Quick PHP Design Question

 
Ranch Hand
Posts: 160
IntelliJ IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys

I've started playing around with PHP and I'm busy writing a simple app which is backed by a MySQL database. I have a Users table in the database, and I want to create an HTML page which will allow you to add/edit/remove users. What is the standard way of doing this? What I have in mind for removing users goes something like this.

1.) User clicks the delete link
2.) Redirect the user's browser to a PHP script with the userID as a GET/POST parameter.
3.) The script deletes the user from the database.
4.) The script redirects the user to the previous page, which should now display one fewer user.

Does this sound sensible?

Also, how do you do validations? Do you validate all data on a form before redirecting to the next page, or do you send the values on your form to a seperate script for validations, which then redirects the user to the next page (if validation succeeds) or back to the previous page (if validation fails).

Thanks for your input.

Cheers,
Riaan
 
Ranch Hand
Posts: 334
2
Netbeans IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Riaan,

That sounds fine to me.

I tend to have operations like delete users to be batch operations with a confirm page.

For example the page that lists (some or all) of the users has a check box in each row of a table. Then a "Do It" and a "Forget It" button which presents a page with all the users to be deleted and a "Confirm" and a "Cancel" button.

The tricky part comes in deciding which users can access that page.

Another option is to have a javascript function that does the confirmation. The advantage is less hits on the server, the disadvantage is mainly learning javascript and maintaining a mixed language project.

Joe
 
You firghten me terribly. I would like to go home now. Here, take this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic