Welcome, Join Guud Forum  Login!

Stats: 2,847 Members  4,418 topics   Date: Tuesday 03 March 2026 at 03:28 PM
General: News-Politics-Others, Jobs-Business-Investments, Health, Religion, Romance, How To
Science & Technology: Science and Tech, Phones and Tech Reviews
Entertainment: Celebrity, Fashion, Sport, Gaming
Schools & Education: University, Polytechnics, College of Education, Scholarships, Travel
Cryptocurrency: Crypto, Ethereum, BNB, Solana, TON, & Others
Webmaster & Security: Security, Programming, Webmasters
All Posts | Create New Post
IMPORTANT UPDATE - March 2026

How to Generate Unique Codes of any Length and Storing on Database in PHP

Guud Forum / / / How to Generate Unique Codes of any Length and Storing on Database in PHP
394 Views  |  0 Comments

How To Use Whatsapp Without Phone Number Or Sim How To Charge Your Phone Using A Banana How To Get N500 Extra Airtime And N500 Data From N100 Recharge On Airtel
How to Generate Unique Codes of any Length and Storing on Database in PHP by SirBee(m): Fri 24, April, 2020 08:26am
To generate Unique characters, Coupon code that can be used for activities like mobile pin recharge cards, Code for registration on a website, special code to grant customers special offers and lots more, then this writeup will guide you.

How to Generate Unique Characters


1. Generate Random characters like numbers, letters, special characters, or combination of all of this.
2. Create a database table then add a column that will store unique character of any length you desire.

This is the two PHP code that will get things done.


1. PHP code to generate the codes

function generateCodes(){
$vv = "WRITE YOUR VARIOUS CHARACTERS HERE";
$valz = explode(' ', $vv);
$sizeOfcontent = sizeof($valz);

for($x=0; $x<19; $x++){
$returnV = rand(0, $sizeOfcontent-1);
if($valz[$returnV] != " "){
$newArray[$x] = $valz[$returnV];
}
if(($x+1)%5==0)$newArray[$x] = " ";//$valz[$returnV];

}
return implode($newArray);
}


2. Storing the Unique code to the Database.

function storeOnDB($db){
$storeResult = array();

for($x=0; $x<20000; $x++){
$pin = theNumber();
$storeResult[] = '("'.$pin.'")';
}

$state = $db->query('insert into table(pin_ttt) values'. implode(',', $storeResult));
if($state) echo 'success';
else echo 'error: '.$db->error;
}

how-to-generate-coupon-code-of-any-length-with-all-characters-numbers-letters-in-php-coding-JPG


1 Like

...

Suggested:

» Money Heist season 5 theories: Alicia’s death ‘sealed’ as fans fear the worst «

» How to Generate Unique Codes of any Length and Storing on Database in PHP «

(» Drop Comment) (» Go Up)

Recommended for you

Federal Inland Revenue Service (firs) Generates ₦66 Billion Naira Between January - May 2020 How To Create Email Address? How To Spot Fake Phones From Original Phones How To Select The Sex Of Your Baby

Sections: Health, Religion, Jobs-Business-Investments, Romance, How To, Phones and Tech Reviews, Science and Tech, Fashion, Sport, Gaming, Celebrity, University, Polytechnics, Scholarships, Travel, College of Education, Crypto, Ethereum, BNB, Solana, TON, & Others, Security, Programming, Webmasters,

Privacy Policy | Terms & Conditions | Contact Us | About Us | Forum Rules | Sitemap

Guud Forum - Copyright © 2019 - 2026. All rights reserved. See How To Advertise.
Disclaimer: Every Guud Forum member is solely responsible for anything that he/she posts or uploads on Guud Forum.