I don't do php at all but this is something I had to learn so to begin our Text Generator open your favorite Text Editor, I have Sublime Text 3 beta. First add the usual html>head>body tags and close the tags, after that let's add our css after body tag add these codes.
<style type="text/css">
.refresh {
-moz-box-shadow:inset 0px 1px 0px 0px #caefab;
-webkit-box-shadow:inset 0px 1px 0px 0px #caefab;
box-shadow:inset 0px 1px 0px 0px #caefab;
background-color:#77d42a;
-moz-border-radius:6px;
-webkit-border-radius:6px;
border-radius:6px;
border:1px solid #268a16;
display:inline-block;
color:#306108;
font-family:arial;
font-size:15px;
font-weight:bold;
padding:6px 24px;
text-decoration:none;
text-shadow:1px 1px 0px #aade7c;
}.refresh:hover {
background-color:#5cb811;
}.refresh:active {
position:relative;
top:1px;
}
h1 {
font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000; font-size:33pt
}
</style>
After that we have a PHP function, add these codes after your css codes
<?php
function Generate() {
$var = "abcdefghijkmnopqrstuvwxyz0123456789";
srand((double)microtime()*1000000);
$i = 0;
$code = '' ;
while ($i <= 6) {
$num = rand() % 35;
$tmp = substr($var, $num, 1);
$code = $code . $tmp;
$i++;
}
return $code;
}
?>
Now finally let's call the function with these codes, just add these codes after the function(php)
<center>
<h1>
<?php
echo Generate();
?>
</h1>
<a href="index.php" class="refresh">Refresh</a>
</center>
NOTE: Replace index.php with your PHP file name.
Now run the PHP, here is image of what we've made
I hope this php tutorial was interesting,Thank you for reading & do share if you thing the article deserves.