Hi, I need some help with my script. Here is what I want. Its an online form that everyone sign up there and once the form is submitted it should give a unique number to everyone. I'm pretty sure its simple but just can't find the hint. Thanks in advance. Regards,
hi, here is the sample that you looking for. ---table details------ table name:user_details fields: fname varchar(15),lname varchar(15),...,UserId varchar(5) ---------------- After submitting the form ,get the details from the form. $uid=substr(uniqid(),-5); insert into table along with the fname,lname,....UserId.etc //where UserId is $uid After successsful insertion , retrieve from the table that UserId wit respect to user and display them. I think this may help you..
Thanks but I didn't mean that, I'm talking about a unique number like a bank draft number. And how can I then echo it? For example: When a user submits the form, name, lastname, subject, will be saved in the record with a unique id number, but in next page followings should be displayed to the user. Id: Name: Lastname: Subject: Draft Number: (This draft number must be unique and generated by php and displayed to the user).
hi, Whether the unique number is vary w.r.t session of the user or remains same and permanent for that user?
I think this may help you better than before. If you register the following details will be shown -------Your details -------- First Name ramesh Last Name kumar Subject hi wish you a happy new year Draft No 2301e849 ----------------------- whenever you want this draftno use the firstname and lastname ,to get from the table.
function genRandomString($length) { $characters = "0123456789abcdefghijklmnopqrstuvwxyz"; // you could remove letters if necessary $draft = ""; for ($p = 0; $p < $length; $p++) { $draft .= $characters[mt_rand(0, strlen($characters))]; } return $draft; } PHP: Usage: $draft = genRandomString(5); // number 5 represents the $length of the draft number you want, longer the better I guess PHP: echo $draft; PHP: You will also need to store this number within your database, just like you store the username and password etc..
Its pretty simple. Just make a function in php to generate random numbers. Once the registration form is submitted, call this function and display the number, it will be unique number. You can also store this number in database for future reference or email to your users.
I want it to be in sequence, and the starting letter should be for example DR1111 so next one should be DR1112 and so on....
Well then wouldn't it be just a simple auto_increment, if you create a second table you could easily tie a users id to a separate draft number(auto_increment) and simple post the letters DR to the html page. ie: post the users id number into table2 CREATE TABLE draft_numbers ( user_id int(255) NOT NULL, draft_number int(255) NOT NULL auto_increment, PRIMARY KEY (draft_number) ) AUTO_INCREMENT=1111
hi, It can be in sequence as you expected. o/p--------------- Your details First Name Ajith Last Name Kumar Subject Welcome Draft No DR1111 --------------- it increase as DR1112,DR1113 etc.....