| | #1 |
| Warrior Member Join Date: 2012
Posts: 20
Thanks: 1
Thanked 1 Time in 1 Post
|
hello people I am new to php and I just wonder I want combination of random number and random string, how can I generate it using php? Any help regarding this is highly appreciated. |
| |
| | #2 |
| Active Warrior Join Date: 2012 Location: United Kingdom
Posts: 60
Thanks: 0
Thanked 5 Times in 5 Posts
|
You can use rand function of php to generate random number and you can take part of the session_id to generate random string , if you combine both of them it will give you required result
|
| |
| | #3 |
| Warrior Member Join Date: 2012
Posts: 20
Thanks: 1
Thanked 1 Time in 1 Post
|
@bug thank you for your help but if you dont mind can you give me an example of what you have explain in php code? Thanks in advance |
| |
| | #4 |
| Active Warrior Join Date: 2012 Location: United Kingdom
Posts: 60
Thanks: 0
Thanked 5 Times in 5 Posts
|
Ok here is a simple code for you. PHP Code: |
| |
| The Following User Says Thank You to bugtrack For This Useful Post: |
| | #5 |
| Warrior Member Join Date: 2012
Posts: 20
Thanks: 1
Thanked 1 Time in 1 Post
|
its working fine right now but when i refresh the page first few characters remains same it only get new characters when i close browswer window and reopen it
|
| |
| | #6 |
| Active Warrior Join Date: 2012 Location: United Kingdom
Posts: 60
Thanks: 0
Thanked 5 Times in 5 Posts
|
You can use PHP Code: |
| |
| | #7 |
| Advanced Warrior War Room Member Join Date: 2006 Location: USA
Posts: 1,907
Thanks: 236
Thanked 1,377 Times in 676 Posts
|
Here's another way to do it... $randomString = md5(rand()); |
| | |
| |
| | #8 |
| Active Warrior War Room Member Join Date: 2013 Location: Florida
Posts: 49
Thanks: 0
Thanked 4 Times in 4 Posts
|
For some reason I'm not able to put this in full. Check out this link: http://stackoverflow.com/a/853898 Pretty cool answer. |
| |
| | #9 | |
| Active Warrior Join Date: 2009
Posts: 31
Thanks: 1
Thanked 4 Times in 4 Posts
|
| |
| |
| | #10 |
| www.freetutorial.co Join Date: 2013 Location: India
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
<?php function RandomTxt() { $chars = "thequickbrownfoxjumpsoverthelazydog"; srand((double)microtime()*1000000); $i = 0; $pass = '' ; while ($i <= 10) { $num = rand() % 33; $tmp = substr($chars, $num, 1); $pass = $pass . $tmp; $i++; } return $pass; } echo RandomTxt(); ?> above code useful to create random text |
| |
| | #11 | |
| Warrior Member Join Date: 2012
Posts: 20
Thanks: 1
Thanked 1 Time in 1 Post
|
You can geenrate very good random string by session and md5 combination
| |
| |
| | #12 |
| SKT Wordpress Themes War Room Member Join Date: 2013 Location: Nagpur
Posts: 65
Thanks: 5
Thanked 28 Times in 11 Posts
|
Hello You can use uniqid(); to randomly ganerate numbers/string |
| | |
| |
| | #13 |
| HyperActive Warrior Join Date: 2010
Posts: 267
Thanks: 5
Thanked 6 Times in 6 Posts
|
Have a look at tthis page PHP Randoms - Random Functions To Do Random Numbers, Random Strings, Random Files, & More |
|
Thanks & Regards, Reach us at dukeduke600@gmail.com. Web Design| Logo Design | Banner Design | Web Development | Mobile Applications [iPhone/iPad/Android/Windows Phone] | |
| |
| | #14 |
| Jim Riley Join Date: 2011 Location: Canada
Posts: 137
Thanks: 60
Thanked 21 Times in 17 Posts
|
This might help you to generate PHP password. You can download the script if required. PHP Password Generator |
| |
|
| Bookmarks |
| Tags |
| generation, php, random, required, string |
| |