How shoulld I create php forms

jsn

Registered
Hi all

I have 3 tables, customers, item orders and products. For customers I need to the following functionalities:
- a data entry to create a new customer
- modify an existing customer
- delete a customer
- select a customer.

What I do not know is how may forms do I need to do that.

One form by functionality, in this case 4 forms, or only one form that will integrate the four functionalities.

I have the same need for products.

Can you please give me some advice ?

thanks
jsn
 
I am certainly no expert in this, but i would think that you could do it with one form, but when i have made some similar things for my self i found it easier for my skillset to just make 4 seperate forms.
 
Who will be using the pages?

If you plan to be the only user of these forms, go for the simple and brutal one form per functionality. This way you can add in any controls you wish with ease. Look-and-feel can remain poor.

If the pages are public, choose the single page option. This will make it easier to maintain a coherent and consistent look and feel for you users. Coding is a little more complex in this case.
 
It's kind of hard to figure out what you mean... if the new customer must be put into your system before you can select them, you will have to have seperate forms because you would have to submit the create query before the select query... If I am understanding you correctly.
 
Hi

Yes this is my problem, how do I know when I create a new customer, that this customer does not already exists ?

The form or forms are for public data entry. The goal is to create a form that allows to take orders over the phone, so the data entry person will have to check if the customer exists, create a customer, and enter the order, selecting the products needed.

The data entry person needs to be able to create, modify or delete customers and/or products. Enter orders, modify and delete them.

How do you build those forms? Any examples somewhere ?

Thanks
jsn
 
You are asking for more than a handful! Definitely look for examples because what you want to do is quite involved. Maybe a friend can walk you through the motions.
 
Your system isn't going to be very simple. It is best to seperate out all the different forms, it will make your system a lot easier than trying to use one form.
 
You can easily get away with the following.

Form A to:
- Add a user
- Edit a user
- Delete a user

Form B to:
- Select a user (though I'm not entirely sure what "select" means)

Then you can have a user log in (then their form will be filled in when they load it), add a checkbox at the bottom a la phpBB "Delete this user" that, if checked, deletes the user.

All this simply has to do with the way you parse the form, since you can have one single php page that calls multiple forms depending on what content you need to serve.

I wrote a job-posting web site for work but I can't, unfortunately, show you the source code. We have one single HTML form that serves for adding, modifying and deleting users, we just pass a function to the form to tell it which we're doing.

How do you know if the user already exists ? Well, mathematically, you can't, since one person could register with different information more than once. But if you use email as a primary key for your customers you should be able to keep track of everyone relatively well.

Does that help ?
 
Thanks, it helps a lot

By select an user, I mean find an user..

about if an user exists or not, I want to know how do you check for duplicates, when entering a new client?

When creating a new user or client, i there a way to check before the data entry person hits "submit" to check if this record is already on the database ?

thanks
jsn
 
Ok well broadly, what my forms did (relly only one script) is you'd POST all the data to the script and see if $HTTP_POST_VARS['SUBMITTED'] was TRUE, if ti was you could do your error checking, like check for duplicate email addresses.

Mysql: SELECT 'email' from 'users' where 'email' = $HTTP_POST_VARS['EMAIL']; then if the rows returned is = 0 you have no duplicates, otherwise you do, and you can tell the user that on the form and maybe redirect them to a login page, or a forgot password or whatever.

To make it even slicker what you can do is some fancy HTML that will replace all the fields in the form with the data they had in case there is an error, but won't do anything if the form is being visited for the first time, like so:
Code:
<input type="text" name="email" id="email" value="<?php echo $HTTP_POST_VARS['email']; ?>" />
 
Back
Top