![]() It's work is equivalent to rolling a dice with as many sides as there are names - each one has an equal probability to be picked. Then simply press the "Pick a Random Name" button and let our randomizer do its job. Our random name picker can handle up to 10,000 names. Copy/paste from a spreadsheet works very well. last name or part of the phone number) to make it even more unique.To generate a single random name, start by feeding the tool with a list of names, one name per row (where "one name" can consist of first and last name, etc.). For this type of use, the time-stamp info can also be combined with some other info (e.g. If you want it more unique, you use microtime and a much longer number. If you limit it to the last six characters, then it is less unique and you will eventually get some duplicates. If you use the full ten characters, then it is unique unless two threads request a number in the same second. In other cases where "semi-unique" is close enough (the number generated is never used on its own to find the associated information), I have used the time stamp as the reference number. ![]() $fc =fopen("reg_ctr.txt","a+") or die("Error!") įlock($fc,LOCK_UN) /* unlock the file */ It locks the file because you could have multiple users trying to do this at the same time (so it needs to be done in a serial fashion). It uses a text file so you don't need a database. If you are using the number as a unique reference number, then this is probably what you want to do. These aren't random, they are very predictable. I have used this little routine to create a unique (ascending) sequence number for registrations. The data could be sent to mail(), to the user and the site owner, or all of the above. Today I am doing accounts so Im excell in my head The data fields are written comma separated csv comma separated values, the initial content of the file is a comma separated list of the field names The new six digit number and the input data are written to the output file and to the browser for the user to read Thanks edwinhermann for the code correction In this concept the validation is lousy(nonexistent), twas just to try it out The number is read, incremented and written back to the erased file after the form is validated The number is initially set to 000000 when the script is installed The serial number is a simple file containing a six digit number, I delete the submit button on the post-submit form on this one so that it is not submitted over n over The form submits to itself, on submission it writes the id number into the id field and displays the data entered in other fields, The input validation is USELESS, I didnt take any care of it, this is a proof of concept not a 'good' script, Not fully tested, creates a csv file of the submitted forms to be loaded into excell, there are dozens of mail handlers already ID,First name, Lastname,email,address,telephone Outputforms.csv is a file in the cgi-bin directory chmod writeable contents Given that countforms.bcnt is a file in the cg-bin directory chmod writeable contents
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |