tags:

views:

39

answers:

1

Hi,

I am having some trouble with some code I am trying to implement. Any help would be much appreciated.

In a database table I have 2 fields:

  1. postcode
  2. area

Every postcode is related to an area.

On a HTML form I have an input field. Users enter their postcode into this field.

My question: what is the best/safest/easiest method, when a user has entered their postcode, to assign it it’s area?

For example:

  1. User enters their postcode
  2. onSubmit the postcode is assigned an area. This can be in a hidden field.

Cheers in advance.

+1  A: 

Do you really need the area at this stage? Why put it in a hidden field?

When you store the postcode in a database table there is no need at all to store the area, because it could/should be retrieved with a query.

When you want to store the area in a cookie, lookup the area once and store it.

Or maybe I didn't understand your problem correctly...

fransre
Hey fransre - thanks for your reply.The area is necessary. The area will be passed to the URL to call the relevant page.Because there are hundreds of postcodes, I have created 20 'areas'. As mentioned above, every postcode is assigned an area.I thought a hidden field would be the easiest way to store the area data to be passed to the URL. I could be very wrong...I hope that is a little clearer. Cheers.