I am developing a project on PHP and MySQL. My problem is "I am unable to show a uniqueID in a textbox like 'GHY00001, GHY00002, etc' auto-incremented everytime i load the page and insert it into the database". I already tried some php tutorials but didn't find usuable to my project. Please help me. I am new to PHP and MySQL so please give me the full code. Thanx in advance.

<?PHP 
//set the random id length 
$random_id_length = 8; 

//generate a random id encrypt it and store it in $rnd_id 
$rnd_id = crypt(uniqid(rand(),1)); 

//to remove any slashes that might have come 
$rnd_id = strip_tags(stripslashes($rnd_id)); 

//Removing any . or / and reversing the string 
$rnd_id = str_replace(".","",$rnd_id); 
$rnd_id = strrev(str_replace("/","",$rnd_id)); 

//finally I take the first 10 characters from the $rnd_id 
$rnd_id = substr($rnd_id,0,$random_id_length); 

echo "Random Id: $rnd_id"; 

?> 

I uses this code to create the random uniqueID but it comes in a format like "mX7I1u9i, ANjLrVXn" after every refresh. I want my unique id in "GHY00001, GHY0002". I have attached the picture to the form. Only Unique ID is auto-generated and rest of the fields will be filled by the user. Hope this will give you some idea. 4173f6a160f160db41d726a36a277de2

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.