Your Ad Here

Thursday, March 26, 2009

Random Character String Form

I'm trying to build an HTML form that has a simple textarea that is submitted. However, once that form is submitted I am trying to display a random character string that is linked to a newly created dynamic page, specifically for that new string.

I am integrating this with Twitter so the string will be a hashtag, which in turn will then be able to look at any Tweets with this hashtag. I'm guessing to write a php script to create the random string and have it displayed. Not quite sure on how to link it.

I think altering this code:


Code:
---------



/**

* The letter l (lowercase L) and the number 1

* have been removed, as they can be mistaken

* for each other.

*/



function createRandomPassword() {



$chars = "abcdefghijkmnopqrstuvwxyz023456789";

srand((double)microtime()*1000000);

$i = 0;

$pass = '' ;



while ($i <= 7) {

$num = rand() % 33;

$tmp = substr($chars, $num, 1);

$pass = $pass . $tmp;

$i++;

}



return $pass;



}



// Usage

$password = createRandomPassword();

echo "Your random password is: $password";



?>
---------
Should suffice to create the random string. Any ideas?

Read More...
Your Ad Here

No comments: