Connecting Tech Pros Worldwide Forums | Help | Site Map

looking for examples

toylet
Guest
 
Posts: n/a
#1: Jul 17 '05
Any website that has discussion about programming a one-to-many input
form (like an invoice) using php and mysql? I want to see how
professional codes it, and handle issues related to the refresh and back
buttons.

--
.~. Might, Courage, Vision. In Linux We Trust.
/ v \ http://www.linux-sxs.org
/( _ )\ Linux 2.4.22-xfs
^ ^ 4:42pm up 2 days 20:21 load average: 0.99 0.97 0.94

Henk Verhoeven
Guest
 
Posts: n/a
#2: Jul 17 '05

re: looking for examples


toylet wrote:[color=blue]
> Any website that has discussion about programming a one-to-many input
> form (like an invoice) using php and mysql? I want to see how
> professional codes it, and handle issues related to the refresh and back
> buttons.
>[/color]
That would depend on the requirements. For example in a shopping cart
the user does only need to change the amount of each item, and delete
it. That can be done in a single page. For an employee making an invoice
there would probably be several input field for one item, so i would
make a page with a form for that and another page for the invoice as a
whole and a table for the items, linking to the Item page.

Becuase of the refresh button i usually do a redirect after a POST.
That is somewhat slower, but it will make te refresh button harmless.

The back button can be more troublesome. For example it should not be
possible in an on line shop to plae an order, press back and incidently
place a second order when ignoring the browser's warning about the
repost. Easy enough to prevent: have an order number and declare the
order final when the customer presses the final OK. Then refuse whatever
transactions on final order. OTOH, i would not go that far for an hours
registation system where the employee can see an overview of what he
enters and can correct eventual 'per abuse' inserts.

maybe the hardest part of form processing is handling input errors.
That's becuase i think you shoud not thow away the errorneous data, but
rather re-present the form and ask the user to change it. Of course i do
not want to build the form generation code twice, so i need a way to
make it work on both data from the database and data from the previous
user form. I use objects for that, but i tend to use object for
everything, i guess others might use an Array.

I am afraid my code is not very representative, becuase it's very OOP
and completely generic (= pritty complex), but you can try out the
working example:
http://www.phppeanuts.org/examples/example2/

discussion about a replacement for the back button:
http://www.phppeanuts.org/site/index...xt+button.html

Greetings,

Henk Verhoeven,
www.phppeanuts.org.



Closed Thread