Some time we develop a form in php like registration form, which require authentication from client side.
For this we generate an authentication code using php and send through email to the client.
This code will generate a random string that is 5 characters long. This 5 characters comes from the string that is in the for loop. We can use the database to store that string at the time of sending email and use for authentication with authentication code.
Code:-
<?php
$string = "0123456789abcdefghijklmnopqrstuvwxyz";
for($i=0;$i<5;$i++){
$position = rand(0,36);
$str .= $string{$position};
}
echo $str;
?>
Hope this php tutorial is useful for you. Keep following www.phpcodeforbeginner.blogspot.in for more help.
No comments:
Post a Comment