Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How do i Generate unique reference number on form submission ?
Old 04-29-2010, 01:27 AM How do i Generate unique reference number on form submission ?
Novice Talker

Posts: 6
Name: Prateek.sem
Trades: 0
Hi,

1. can anyone give me some direction on this
2. will it require a database

Thanks
Prateek.sem is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-29-2010, 03:08 AM Re: How do i Generate unique reference number on form submission ?
MattGoucher's Avatar
Skilled Talker

Posts: 64
Name: Matt
Location: California
Trades: 0
The actual generation of a random number will not require a database. However, if you are looking to store the random string for later use, then you will need a database.

PHP Code:
<?php
    $Number 
round(rand(190000));
    echo 
$Number;
?>
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Invalid Code On A New Website Is Like Having A New Car With A Broken Windshield
MattGoucher is offline
Reply With Quote
View Public Profile Visit MattGoucher's homepage!
 
Old 04-29-2010, 11:04 AM Re: How do i Generate unique reference number on form submission ?
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 680
Name: Lashtal
Trades: 0
imagine you could store the number in a .txt by appending it thereto, using fopen and fwrite

but imagine, for security reasons, this isn't highly recommended.
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
Reply With Quote
View Public Profile
 
Old 04-29-2010, 11:10 AM Re: How do i Generate unique reference number on form submission ?
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
To make a ref number i do a few things.

i first generate 2 sets of random numbers.
then i generate a number based on the current timestamp.

I then concatenate them

Refcode = rand1 + timestampNumber + rand2

using a date and timestamp to make a number and some random numbers thrown in will make sure the number is never used again ( as the current date and time wont happen again! )
Ie:
041042223287
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE



Last edited by lynxus; 04-29-2010 at 11:11 AM..
lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Old 04-29-2010, 11:18 AM Re: How do i Generate unique reference number on form submission ?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Use the current session ID.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to How do i Generate unique reference number on form submission ?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.86618 seconds with 12 queries