sKunKbad Posted May 30, 2009 Share Posted May 30, 2009 I'd like a query OR the ability to set a column's properties in the database, so that as I insert a new record, the value of the field in this column would be a unique AND random 10 digit number. I'm using phpMyAdmin, as I'm not a MySQL guru. Can I set the column in the database to generate this type of number, instead of auto-increment? Currently the column is just set as INT w/ auto-increment. I know I could probably do this with multiple queries to the database to confirm that a php generated random number isn't currently in use, but I'm looking for a cleaner way. Is what I want to do possible? Quote Link to comment https://forums.phpfreaks.com/topic/160231-solved-insert-a-unique-and-random-10-digit-number-instead-of-auto-increment/ Share on other sites More sharing options...
Ken2k7 Posted May 30, 2009 Share Posted May 30, 2009 Well MySQL has a RAND() function, but there still can be a way to have a repeated number. I don't know of any other way but to generate a number and query the DB to see if the number exists. Too troublesome for what its worth. May I ask why you wish to do that? Quote Link to comment https://forums.phpfreaks.com/topic/160231-solved-insert-a-unique-and-random-10-digit-number-instead-of-auto-increment/#findComment-845468 Share on other sites More sharing options...
sKunKbad Posted May 30, 2009 Author Share Posted May 30, 2009 Well, I guess I had this idea in my head that my user id's would be more secure if they were random, and not auto-incremented. Even though the rest of the authentication system is secure, it would be much harder to guess a user's ID, in case somebody was trying to modify their cookie (or a cookie). Quote Link to comment https://forums.phpfreaks.com/topic/160231-solved-insert-a-unique-and-random-10-digit-number-instead-of-auto-increment/#findComment-845473 Share on other sites More sharing options...
Ken2k7 Posted May 30, 2009 Share Posted May 30, 2009 You can store a session id or a session key. You shouldn't depend on cookie data. Quote Link to comment https://forums.phpfreaks.com/topic/160231-solved-insert-a-unique-and-random-10-digit-number-instead-of-auto-increment/#findComment-845505 Share on other sites More sharing options...
sKunKbad Posted May 30, 2009 Author Share Posted May 30, 2009 I am using session data and a second cookie. The data for authentication is in the session, so I guess there's no point in worrying about cookie modification. I appreciate the response. Sometimes after a long day I get foggy headed. Quote Link to comment https://forums.phpfreaks.com/topic/160231-solved-insert-a-unique-and-random-10-digit-number-instead-of-auto-increment/#findComment-845515 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.