You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.
Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"
// Generate a random 16-digit number
$random_number = str_pad(mt_rand(1, 9999999999999999), 16, '0', STR_PAD_LEFT);
// Format the number with dashes every 4 digits
$random_number = chunk_split($random_number, 4, '-');
// Remove the last dash
$random_number = rtrim($random_number, '-');
// Output the formatted number
echo $random_number;
<?php
function generateRandomNumber() {
$part1 = str_pad(mt_rand(0, 9999), 4, '0', STR_PAD_LEFT);
$part2 = str_pad(mt_rand(0, 9999), 4, '0', STR_PAD_LEFT);
$part3 = str_pad(mt_rand(0, 9999), 4, '0', STR_PAD_LEFT);
$part4 = str_pad(mt_rand(0, 999), 3, '0', STR_PAD_LEFT);
return "{$part1}-{$part2}-{$part3}-{$part4}";
}
if (isset($_POST['generate'])) {
$randomNumber = generateRandomNumber();
} else {
$randomNumber = "";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Generate Random Number</title>
</head>
<body>
<form method="post">
<label for="number">Random Number:</label>
<input type="text" name="number" id="number" value="<?php echo $randomNumber; ?>" readonly><br><br>
<input type="submit" name="generate" value="Generate">
</form>
</body>
</html>
<?php
function generateRandomNumber() {
$random_bytes = random_bytes(8);
$num = hexdec(bin2hex($random_bytes)) % (10 ** 16); // Convert random bytes to a 16-digit number
$formatted_num = sprintf('%04d-%04d-%04d-%04d', $num / 10 ** 12, ($num / 10 ** 8) % 10 ** 4, ($num / 10 ** 4) % 10 ** 4, $num % 10 ** 4); // Format number with hyphens
return $formatted_num;
}
?>
<html>
<head>
<title>Random Number Generator</title>
</head>
<body>
<form>
<label>Random Number:</label>
<input type="text" name="random_number" value="<?php echo generateRandomNumber(); ?>" readonly>
<br>
<button type="submit">Generate Random Number</button>
</form>
</body>
</html>
What is your problem with this code exactly?Please provide the required code
And if you need any modification I will help you
Code:<?php function generateRandomNumber() { $part1 = str_pad(mt_rand(0, 9999), 4, '0', STR_PAD_LEFT); $part2 = str_pad(mt_rand(0, 9999), 4, '0', STR_PAD_LEFT); $part3 = str_pad(mt_rand(0, 9999), 4, '0', STR_PAD_LEFT); $part4 = str_pad(mt_rand(0, 999), 3, '0', STR_PAD_LEFT); return "{$part1}-{$part2}-{$part3}-{$part4}"; } if (isset($_POST['generate'])) { $randomNumber = generateRandomNumber(); } else { $randomNumber = ""; } ?> <!DOCTYPE html> <html> <head> <title>Generate Random Number</title> </head> <body> <form method="post"> <label for="number">Random Number:</label> <input type="text" name="number" id="number" value="<?php echo $randomNumber; ?>" readonly><br><br> <input type="submit" name="generate" value="Generate"> </form> </body> </html>
$randomNumber = isset($_POST['generate']) ? generateRandomNumber() : "";
We get it, advertisements are annoying!
However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.
If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.