View: 2152|Reply: 12
|
To Otai MySql + PHP (2)
[Copy link]
|
|
Nk mintak tlg skit lg la..hehe
Nk code utk assign unique id utk new registered user...unique id tu mestilah mengandungi 12 digit nombor sahaja...
Tq. |
|
|
|
|
|
|
|
Reply #1 jebeng's post
setkan column utk id tu as int dan jadikan primary key. pastu buat auto increment. utk dapat 12 digit, start jek dengan 100000000000.
so ahli kedua akan dapat id = 100000000001;
hehehe..ni care plg simple aa aku rase, takde kene ngene ngan php, only db aje |
|
|
|
|
|
|
|
Reply #2 dCrook's post
cdgn yg bgus..tp x menepati la...mksd sy cam no akaun bank tu...unique nombor utk membership...ade care die x? |
|
|
|
|
|
|
|
Reply #3 jebeng's post
maksud ko, ko nak nombor cam 112312301217? okeh..nombor nih ade sangkut paut tak dengan tempat ? cthnya negeri selangor : 1400 , jadi nombor dia 1400 65473212 .. 8 nombor terakhir tu nombor ahli .. camtu ke? |
|
|
|
|
|
|
|
Reply #4 dCrook's post
yup..xder kaitan pe2 pon..just random n unique id...tu jer...nant lg pyh lak huhu |
|
|
|
|
|
|
|
kalau nak buat mcm no acc bank tu ko buat la string function... nak bagi contoh pun aku tak tau ko nk mcm mana? |
|
|
|
|
|
|
|
kalu amik tarikh + time cast jadik string amacam? |
|
|
|
|
|
|
|
kalau x silap aku hang leh guna built in function rand()
consult php manul web site |
|
|
|
|
|
|
|
kalo pki rand() tu leh jdk unique ker?mksudnye no. yg di assign x leh same...
tq...
cth :
MR. A 01234566789312
MR. B 65935989565697
[ Last edited by jebeng at 27-1-2008 01:22 PM ] |
|
|
|
|
|
|
|
Cth saje : -
<?php //creates a unique id with the 'about' prefix
$a = uniqid(about);
echo $a;
echo "<br>";
//creates a longer unique id with the 'about' prefix
$b = uniqid (about, true);
Echo $b;
echo "<br>";
//creates a unique ID with a random number as a prefix - more secure than a static prefix
$c = uniqid (rand (),true);
echo $c;
echo "<br>";
//this md5 encrypts the username from above, so its ready to be stored in your database
$md5c = md5($c);
echo $md5c;
<table>
<tr>
<td>Name:</td>
<td>
<input type="text" name="name" value="" maxlength="100" />
</td>
</tr>
<tr>
<td>IC.No :</td>
<td>
<p><input type="number" name="ic" value="" maxlength="25" size="25"/> </p>
</td>
</tr>
<tr><td>SPM/MCE:</td>
<td>
<input type="text" name="batch" value="yyyy" maxlength="100" />
</td>
</tr>
<tr>
<td>Email:</td>
<td>
<input type="text" name="email" value="" maxlength="100" />
</td>
</tr>
<tr>
<td valign=top>Address:</td>
<td valign=top>
<input type="text" name="address" value="" maxlength="100" />
</td>
</tr>
<tr>
<td>City:</td>
<td>
<input type="text" name="City" value="" maxlength="100" />
</td>
</tr>
<td>Postcode:</td>
<td>
<input type="text" name="poskod" value="" maxlength="100" />
</td>
</tr>
<tr><td>State:</td>
<td>
<input type="text" name="state" value="" maxlength="100" />
</td>
</tr>
<tr>
<td>Tel:</td>
<td>
<input type="text" name="telephone" value="" maxlength="100" />
</td>
<tr>
<td>Occupation:</td>
<td>
<input type="text" name="occupation" value="" maxlength="100" />
</td>
</tr>
<tr>
<td>Company:</td>
<td>
<input type="text" name="company" value="" maxlength="100" />
</td>
</tr>
<tr>
<td>Verify:</td>
<td>
{imageverification}
</td>
</tr>
<tr><td> </td>
<td>
<input type="submit" value="Submit" />
</td>
</tr>
</table>
?> |
|
|
|
|
|
|
|
bile user isi form tu n send..kat database akan auto assign unique number/id kat user td tu...tu example jer,x tau btol ke x...dh phm ker?hehe....so bile kite query blk...report tu akan mcm ni :-
Id : ( no. yg diassign td )
Nama :
Alamat:
etc....
sori,aku pong bkn hbat sgt..just hack n use jer...huhu |
|
|
|
|
|
|
|
Reply #11 jebeng's post
Guna IC Number + Row ID = bole create unique ID |
|
|
|
|
|
|
|
generate no
kalo na generate no yg ade kaitan cmne..
cthnye..
co = 01
unit = 02
dept = 04
category = 05
subcategory = 09
running no = 1004
co, unit,dept,category,subcat sume user select kat dynamic selection menu..user akan select sume tu..then sys akan generate..cmne na wat |
|
|
|
|
|
|
| |
|