Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

October 19, 2015

Random Strings Generator in PHP

Hello! if you are trying to create a random Number/ String Generator that never overlaps in PHP, you need to know how to use rand(), md5, and microtime().
for explanation, md5 is encrypting the number from microtime(random number that comes from the current time) and getting 0 to 26 numbers by using substr.
Try Copy and Pasting it to your Server with extension .php and run to get better idea of how this works.
Run example is on

<!DOCTYPE html>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
   Random String Generator v0.1: <input type="number" name="fname">
   <input type="submit">

<table style="border: px solid #333;">

     // collect value of input field
     $number = $_REQUEST['fname'];

     if($number <= 0){
echo "<br>"; //Next Line
echo '<td style="border: 1px solid #333">'."One or more please".'</td>';
else if($number >= 1001){
echo "<br>"; //Next Line
echo '<td style="border: 1px solid #333">'."Number needs to be less than 1000".'</td>';
else {
echo "<br>"; //Next Line
echo '<td style="border: 1px solid #333;">'."Created Number:"."<br>".'</td>';

$rand = substr(md5(microtime()),rand(0,26),100);
echo '<tr>';
echo '<td style="border: 1px solid #333;">'.$rand."<br>".'</td>';
echo '</tr>';



1 comment:

  1. I'm gone to say to my little brother, that he should also go to see this website on regular basis to get updated from most up-to-date gossip. facebook log in facebook