6 Replies - 432 Views - Last Post: 05 April 2012 - 07:54 PM Rate Topic: -----

#1 Syfer  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 190
  • Joined: 08-October 10

about auto inc of usernames and pass

Posted 04 April 2012 - 11:22 PM

i'm not sure if the title is correct but
what i want to do is to make a username and its default password is the username also
like patient01 onwards if a user registers

so after filling up the personal infos after pressing the register .. the page will prompt a username and its password to the user... or ill a admin is the only one who can register a user...

any advice codes to help me out to start it?
Is This A Good Question/Topic? 0
  • +

Replies To: about auto inc of usernames and pass

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3479
  • View blog
  • Posts: 10,025
  • Joined: 08-June 10

Re: about auto inc of usernames and pass

Posted 04 April 2012 - 11:26 PM

would it matter if you let the user create the password himself? otherwise every other user (given (s)he is smart enough) could log in with every other username known, exploiting the lazyness of people who generally do not change their password, unless forced to do so.
Was This Post Helpful? 1
  • +
  • -

#3 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3710
  • View blog
  • Posts: 5,958
  • Joined: 08-June 10

Re: about auto inc of usernames and pass

Posted 05 April 2012 - 01:02 AM

Yea, this seems like a really really bad idea. It's a security vulnerability just begging to be abused.

If you have some compelling reason for not letting the user to provide his/her own password, you should at least generate a random password.
Was This Post Helpful? 1
  • +
  • -

#4 Syfer  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 190
  • Joined: 08-October 10

Re: about auto inc of usernames and pass

Posted 05 April 2012 - 02:27 AM

View PostDormilich, on 04 April 2012 - 11:26 PM, said:

would it matter if you let the user create the password himself? otherwise every other user (given (s)he is smart enough) could log in with every other username known, exploiting the lazyness of people who generally do not change their password, unless forced to do so.



View PostAtli, on 05 April 2012 - 01:02 AM, said:

Yea, this seems like a really really bad idea. It's a security vulnerability just begging to be abused.

If you have some compelling reason for not letting the user to provide his/her own password, you should at least generate a random password.


Well you guys are right , well it makes a username : from patient01 onwards
and random generates a password then

but how will i start it? or any code samples or ?
Was This Post Helpful? 0
  • +
  • -

#5 sBorg  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 28
  • Joined: 24-March 12

Re: about auto inc of usernames and pass

Posted 05 April 2012 - 04:22 AM

Try searching for existing functions/solutions!

http://www.totallyph...random-password
Was This Post Helpful? 1
  • +
  • -

#6 Duckington  Icon User is offline

  • D.I.C Addict

Reputation: 169
  • View blog
  • Posts: 606
  • Joined: 12-October 09

Re: about auto inc of usernames and pass

Posted 05 April 2012 - 06:21 AM

function generateRandomCode($length)
    {
        
        $str = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz01234567890123456789!@_?';
        $num = strlen($str) - 1;
        $ret = '';
        
        for($i = 0; $i < $length; $i++)
        {
            $rand = mt_rand(0, $num);
            $ret .= $str[$rand];
        }
       
        return $ret;
        
    }



Just give a length when you call it. You can add/remove whatever characters you want from the string, if you don't want some of those to be used.
Was This Post Helpful? 1
  • +
  • -

#7 Syfer  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 190
  • Joined: 08-October 10

Re: about auto inc of usernames and pass

Posted 05 April 2012 - 07:54 PM

thanks

This post has been edited by Syfer: 05 April 2012 - 08:28 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1