By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,641 Members | 1,685 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,641 IT Pros & Developers. It's quick & easy.

Secure a unique ID before inserting into DB

P: n/a
Hello,
I am writing an application to handle support requests, and the user
needs to have his request number printed out in front of him even before
he hits the "submit" button. I have no idea how to secure a unique
number without relying on a database.
How could this be done ?

thanks.

--
luc wastiaux - email: du*******@airpost.net

Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
> I am writing an application to handle support requests, and the user
needs to have his request number printed out in front of him even before
he hits the "submit" button. I have no idea how to secure a unique
number without relying on a database.
How could this be done ?


how about inserting a record before submit? In other words, you have php
file that displays form to enter request. Before you do anything in that
file insert a record, and put in some column of it something like
"finalized='F' ,and then display form now that you know the Id.

Then when you process submit, just update the existing record, and turn
"finalized='T'".

rush
--
http://www.templatetamer.com/

Jul 17 '05 #2

P: n/a
or you can store a number in a file and everytime you need to display the
page read it, increment it and save the file. Its something like doing page
view counters.

sanjay
"rush" <pi**@rush.avalon.hr> wrote in message
news:bn**********@ls219.htnet.hr...
| > I am writing an application to handle support requests, and the user
| > needs to have his request number printed out in front of him even before
| > he hits the "submit" button. I have no idea how to secure a unique
| > number without relying on a database.
| > How could this be done ?
|
| how about inserting a record before submit? In other words, you have php
| file that displays form to enter request. Before you do anything in that
| file insert a record, and put in some column of it something like
| "finalized='F' ,and then display form now that you know the Id.
|
| Then when you process submit, just update the existing record, and turn
| "finalized='T'".
|
| rush
| --
| http://www.templatetamer.com/
|
|
|
Jul 17 '05 #3

P: n/a
Rob
You could base the number on the Unix time stamp. That would always be
unique (since it's just one long string of seconds since 1970). Then append
that number with some other identifier (IP address, User ID, etc) Then,
when they hit "submit", just save it.

Using that method would also automatically give you the date/time that the
request ticket was created; all you'd have to do is parse and decode the
first part of the request ticket.

Here's a base reference. Look at all the date/time references in the PHP
manual as well.

http://www.phpfreaks.com/quickcode/H...Numbers/17.php


Rob
"luc wastiaux" <du*******@airpost.net> wrote in message
news:bn********@enews4.newsguy.com...
Hello,
I am writing an application to handle support requests, and the user
needs to have his request number printed out in front of him even before
he hits the "submit" button. I have no idea how to secure a unique
number without relying on a database.
How could this be done ?

thanks.

--
luc wastiaux - email: du*******@airpost.net

Jul 17 '05 #4

P: n/a
Rob wrote on Wednesday 22 October 2003 10:07:
You could base the number on the Unix time stamp. That would always be
unique (since it's just one long string of seconds since 1970). Then
append
that number with some other identifier (IP address, User ID, etc) Then,
when they hit "submit", just save it.

Using that method would also automatically give you the date/time that the
request ticket was created; all you'd have to do is parse and decode the
first part of the request ticket.


That wouldn't work for simultaneous users who are using a proxy server.
i.e., if at any point that app was used by 2 or more users simultaneously
under the same proxy, it would have to use a different logic for generating
unique IDs.

One that I've seen and used a lot is similar to (or expanding of) what
Sanjay suggested with the difference that there's many numbers and they are
all stored in a database table.

So, you have a table:
uniqueid
----------
id

and a few number records (depending on user load) like:

150, 151, 152, 153, 154, 155

When you want a new ID, you grab the lowest ID (150), delete it, and insert
a new one at the end (156). Sometimes, and depending on database platform,
it is recommended to use transactions, as well as row-level, page, or table
locking to handle [rare, depending on the user load] truly simultaneous
requests.

This is a brief comment. There are some views and papers published on this
by experts. I'm sure if the OP searches, he will find some nice ways to
accomplish this.

--
Business Web Solutions
ActiveLink, LLC
www.active-link.com/intranet/
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.