PDA

View Full Version : Will Design For Code..


MEYOR
09-30-2002, 08:47 PM
Hey peeps .. im in need of a FORM.. that generates a random #..

Details..

this form will be used for a Members sign up for a cycling site..
members will get discounts/other great stuff if they sign up.. i need a sign up form that sends the person who registers a random # (i.e H&%4r or sumthing) and also saves it to a data base on our server.. reason for this .. is so we can identify our registered members . they will give us this code and we can simply look in the data base and identify this person and offer them the great deals. i will design a complete website in return for a script like or similar to this..my design skills consist of .. 3 yrs of graphic design experience.. with an AA/BA in viusal communications..
www.ecyclists.com is the site im needing this script for.. thank you.

whammy
10-02-2002, 01:34 PM
What kind of database are you using?

The reason I ask is databases use something called a "Primary Key" which is usually an "AutoNumber" or "autoincrement" field - so you can identify records uniquely.

Also, if your database is SQL Server, it can generate a unique id for you as well...

MEYOR
10-02-2002, 06:33 PM
yes its a SQL data base...

my hostingis from www.mediatemple.net

whammy
10-03-2002, 02:45 AM
Since that is the case, you can have the SQL Server database generate a "Unique ID" for you - there is no reason to use a randomization function. :D

I would discuss with your host how to implement this functionality - it should be fairly simple. :D

Ökii
10-03-2002, 11:54 AM
Personally (like on a multiple admin scriptlet), I'd just leave a field in the members database for `accesslevel` and use the usual username/password combo for finding members.

table `members` [id a-i p i u][username vchar100][password vchar100][accesslevel int10]

eg 123 Sid Biker ****** 12
$r = mysql_query("SELECT accesslevel FROM `members` WHERE username='$input1' AND password='my_crypt_funct($input2)'");
.. if($accesslevel > 10) {// show the great deals }

Mostly it would depend upon your current database layout and how you are logging members at the moment.
E-mail/PM me if you want.

MEYOR
10-03-2002, 11:24 PM
i have zero coding knowledge ..the reason for the random # thing is the site im building have partners in this case a internet company they will do discounts to peopel who become mebers of the site.. so they want a random # generated so they can indentify that they are a member.. so people wont be taking advantage of the deal .. so they will have to sign up to get the deals n such .

MEYOR
10-03-2002, 11:27 PM
OH YAH GREAT FORUMS BY THE WAY!!!!

whammy
10-04-2002, 02:36 AM
I am using the same kind of "accesslevel" deal in my member database... and Ökii - I don't use this!...

If you really want a client-side random string function, I can provide a pretty much bulletproof solution for you... although I will not guarantee it totally!


function UniqueString(){
var mydate = new Date;
var myday = mydate.getDate();
var mymonth = mydate.getMonth()+1;
var myyear = mydate.getFullYear().toString().slice(2,4);
var myhour = mydate.getHours();
var myminutes = mydate.getMinutes();
var myseconds = mydate.getSeconds();
if(myday < 10) myday = "0" + myday;
if(mymonth < 10) mymonth = "0" + mymonth;
if(myhour < 10) myhour = "0" + myhour;
if(myminutes < 10) myminutes = "0" + myminutes;
if(myseconds < 10) myseconds = "0" + myseconds;
var datearray = new Array(mymonth,myday,myyear,myhour,myminutes,myseconds);
var uniq = "";
for(i=0;i<datearray.length;i++){
for(z=0;z<2;z++){
var which = Math.round(Math.random()*1);
if(which==0){
x = String.fromCharCode(64 + (Math.round(Math.random()*25)+1));
}
else{
x = String.fromCharCode(47 + (Math.round(Math.random()*9)+1));
}
uniq += x;
}
uniq += datearray[i];
}
return uniq;
}


The above is in javascript... but it would be nearly impossible to get the same string because it also uses date/time functions in addition to randomness.

Note that I said "nearly impossible"... which means that it IS possible that a duplicate string would be created, but the odds against it are probably more than a billion to one. (and you can take that opinion with a grain of salt as well... since I'm no statistics major.) :D

firepages
10-04-2002, 05:52 AM
uniqid() :D

<?
$unique_token=md5(uniqid(rand(),1));
?>