Re: [PHP] random string
You have an array of names and you want to choose a random name. is it? try thinking some thing about arrays, keys numbers, key count, and such Ross wrote: Hi, I want to randomise a string $myrandom = rand(ross, andrea); echo $myrandom; I know this doesn't work but is there a built in function to do this? R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- View this message in context: http://www.nabble.com/random-string-tf2459193.html#a6881109 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] random string
Hi, I want to randomise a string $myrandom = rand(ross, andrea); echo $myrandom; I know this doesn't work but is there a built in function to do this? R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] random string
Hi, I want to randomise a string $myrandom = rand(ross, andrea); echo $myrandom; I know this doesn't work but is there a built in function to do this? R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] random string
On 10/17/06, Ross [EMAIL PROTECTED] wrote: Hi, I want to randomise a string $myrandom = rand(ross, andrea); I suggest : $array_name = array(rose,andrea); $myrandom = array_rand($array_name); echo $myrandom[0]; Brice. I know this doesn't work but is there a built in function to do this? R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] random string
On Tue, October 17, 2006 7:30 am, Ross wrote: I want to randomise a string $myrandom = rand(ross, andrea); echo $myrandom; I know this doesn't work but is there a built in function to do this? I'm not real clear on what this is... Choose a string at random from an array? $possibles = array('ross', 'andrea'); shuffle($possibles); echo $possibles[0]; Or are you trying to compose a new string of randomly-selected characters of a bunch of other strings? Some combination of these functions might be in the recipe: http://php.net/mt_rand http://php.net/shuffle http://php.net/explode -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Random String Generation
Hello: What I am trying to do is to create a email verification routine with PHP. When people register on the site they will get an email sent to them with a link such as http://mysite.com/activation.php?ID=ghjghjg367ghjlkj9hjlkjhn0 That way when they click on the link it will verify the code against the database and activate their account. Does anyone know an easy way to create this string? Thank you, Mike Walth CinoFusion -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Random String Generation
On Thursday 13 March 2003 02:49, Mike Walth wrote: You have started a new thread by taking an existing posting and replying to it while you changed the subject. That is bad, because it breaks threading. Whenever you reply to a message, your mail client generates a References: header that tells all recipients which posting(s) your posting refers to. A mail client uses this information to build a threaded view (tree view) of the postings. With your posting style you successfully torpedoed this useful feature; your posting shows up within an existing thread it has nothing to do with. Always do a fresh post when you want to start a new thread. To achieve this, click on New message instead of Reply within your mail client, and enter the list address as the recipient. You can save the list address in your address book for convenience. What I am trying to do is to create a email verification routine with PHP. When people register on the site they will get an email sent to them with a link such as http://mysite.com/activation.php?ID=ghjghjg367ghjlkj9hjlkjhn0 That way when they click on the link it will verify the code against the database and activate their account. Does anyone know an easy way to create this string? Have a look at uniqid(). -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Promise her anything, but give her Exxon unleaded. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Random String Generation
Mike, This is can be simple or complex depending on how complex you get. Here is an example that should work. function getRandString() { $NumOfElements = 5; // Chooses that number of elements from the Element Array $ElementArray = array(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z); $Total = count($ElementArray); $String = ; for ($C=0; $C$NumOfElements; $C++) { $RNum = rand(0, $Total); $String .= $ElementArray[$RNum]; } return $String; } With the settings this functions loops through and creates a string that is 5 elements in length. You can tell it to add or subtract numbers by changing the value of NumOfElements or change the elements that are returned by changing the value of ElementArray. I hope this helped. Jonathan Pitcher On Wednesday, March 12, 2003, at 12:49 PM, Mike Walth wrote: Hello: What I am trying to do is to create a email verification routine with PHP. When people register on the site they will get an email sent to them with a link such as http://mysite.com/activation.php?ID=ghjghjg367ghjlkj9hjlkjhn0 That way when they click on the link it will verify the code against the database and activate their account. Does anyone know an easy way to create this string? Thank you, Mike Walth CinoFusion -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Random String Generation
The method I use is to take their user_id or email and create an HMAC (hashed message authentication code) by hashing it with a secret key on my end. This way the activation link looks like the following: http://mysite.com/activation.php?user_id=petejID=ghjghjg367ghjlkj9hjlkj THe activation script takes the user_id they passed in and hashes it with the secret key again. The result should match the ID they passed. Easy and pretty secure. HTH. Pete. Mike Walth wrote: Hello: What I am trying to do is to create a email verification routine with PHP. When people register on the site they will get an email sent to them with a link such as http://mysite.com/activation.php?ID=ghjghjg367ghjlkj9hjlkjhn0 That way when they click on the link it will verify the code against the database and activate their account. Does anyone know an easy way to create this string? Thank you, Mike Walth CinoFusion -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Random String Generation
At 19:56 12.03.2003, you said: [snip] On Thursday 13 March 2003 02:49, Mike Walth wrote: You have started a new thread by taking an existing posting and replying to it while you changed the subject. ...etc... [snip] you _do_ have a stationery for that, do you? *g* -- O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Random String Generation
on 13/03/03 5:49 AM, Mike Walth ([EMAIL PROTECTED]) wrote: Hello: What I am trying to do is to create a email verification routine with PHP. When people register on the site they will get an email sent to them with a link such as http://mysite.com/activation.php?ID=ghjghjg367ghjlkj9hjlkjhn0 what you want to do is use the random string as a verifying of an id... so their email address gets added to the db, with an id and a random value. your table may look like this: id email stamp confirm Then you send an email out with a link. For the fourth email address you add, it may look like this: http://site.com/confirm.php?id=4c=182648 confirm.php grabs the id, checks the confirm code, and if all is well, resets the confirm code to 1 (true), or yes, or whatever you choose. To get the random value, include this function that I just wrote for someone else in a different thread: ? function randNumber($min=1000,$max=9) { // build a seed list($usec, $sec) = explode(' ', microtime()); $seed = (float) $sec + ((float) $usec * 10); // seed random generator srand($seed); // return random number return rand($min,$max); } ? Since the min is 1000, it will never be '1'. Hope this helps, Justin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Random String Generation
What I am trying to do is to create a email verification routine with PHP. When people register on the site they will get an email sent to them with a link such as http://mysite.com/activation.php?ID=ghjghjg367ghjlkj9hjlkjhn0 That way when they click on the link it will verify the code against the database and activate their account. Does anyone know an easy way to create this string? Use uniqid(). The manual page shows you how to create one along with md5() that'll be 32 chars (128 bits) long. Pretty hard for someone to guess. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Random string (was Header sent problem)
I found that the Header already sent problem was caused by the Random Password Generator I'm using, even if I place this function on the bottom of the same file I'm trying to open an just call for the result. So, to avoid this issue, I need another method of generating a random number or string of some sort like using the actual time which I can place inside the setcookie function directly... anyone knows what can I use? Thanks in advance, Cesar L. Aracena [EMAIL PROTECTED] [EMAIL PROTECTED] (0299) 156-356688 Neuquén (8300) Capital Argentina -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Random string (was Header sent problem)
The function is not the real problem, you just need to find any characters (even white) outside ?php ? Cesar Aracena wrote: I found that the Header already sent problem was caused by the Random Password Generator I'm using, even if I place this function on the bottom of the same file I'm trying to open an just call for the result. So, to avoid this issue, I need another method of generating a random number or string of some sort like using the actual time which I can place inside the setcookie function directly... anyone knows what can I use? Thanks in advance, Cesar L. Aracena [EMAIL PROTECTED] [EMAIL PROTECTED] (0299) 156-356688 Neuquén (8300) Capital Argentina -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Random string (was Header sent problem)
I found that the Header already sent problem was caused by the Random Password Generator I'm using, even if I place this function on the bottom of the same file I'm trying to open an just call for the result. So, to avoid this issue, I need another method of generating a random number or string of some sort like using the actual time which I can place inside the setcookie function directly... anyone knows what can I use? If the function is the problem, then stop echoing or printing anything in the function, before it, or after it. Make sure there is nothing outside of the ? And ? tags, especially an extra line break after the closing ? of the file if it's an include file. And, you can use uniqid() to create a random string. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Random String of n Length
Generate a Random Password with PHP http://www.linuxguruz.org/z.php?id=305 # Note: 1. You can add more charactors, numbers or lower case charactors # to '$possible_charactors' is you wish. # 2. You can change the string length, for example, # echo 'Random_Password(16);' for 16 charactors. [EMAIL PROTECTED] #PHP IRC EfNet #LinuxSupport IRC EfNet http://www.LinuxGuruz.org On Tue, 13 Feb 2001, Jonathan Sharp wrote: I want to generate a random string of characters of n Length...what's the easiest way to do this? Thanks, -Jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]