Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

unique five-digit number / mini referral system

Asked Modified Viewed 1,848 times
K
karix094
K
  • Newbie, joined since
  • Contributed 7 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
asked
Newbie

I do not know English well.
I use translate.google.pl
Hello.
I need some changes in PHP-Fusion 9.10
Access to the site will only be for logged in users, ie "Maintenance mode:" (I think I can handle it).

but I need:::
[bcolor=#3300ff]>[/bcolor] After registration, each user will receive a unique five-digit number. e.g. 37859,
cannot repeat.
Each user will have his own
[bcolor=#3300ff]>[/bcolor] This number will be displayed after logging in in the side panel. It will not be displayed for all users but for several user groups.
[bcolor=#3300ff]>[/bcolor] Each user will have a unique five-digit number
[bcolor=#3300ff]>[/bcolor] This number will be assigned to you (you will have this number)
but if you are a regular user it will not be displayed to you
[bcolor=#3300ff]>[/bcolor] If admin adds you to the "xyz" group, you will see this number
[bcolor=#3300ff]>[/bcolor] After entering the home page (a user who is not registered), the website will ask for a five-digit number.
[bcolor=#3300ff]>[/bcolor] After entering the number, the user will be redirected to the page with the information of the user to whom the number is assigned

Example:::
* My five-digit number is 86420
You enter the website:
http://dt.info.pl/
* A table will appear on the page in which you will have to enter a five-digit number. that is: 86420
* After entering the number, it redirects to the page with information about the user to whom the number is assigned:
http://dt.info.pl/account.php?ref=4
4 is my profile ID
This is the same:
http://dt.info.pl/profile.php?lookup=4
Edited by karix094 on 13-10-2021 15:42,
1 reply

7 posts

D
douwe_yntema
D
  • Senior Member, joined since
  • Contributed 667 posts on the community forums.
  • Started 57 threads in the forums
  • Answered 1 question
answered
Senior Member

You can make a userfield to display the random number in the panel, but restrict it to specific usergroups. This can be done in the panel or in the code for the user field.

Fill the user field with a random number at registration. This can be done via trigger in the database.
Edited by douwe_yntema on 15-10-2021 19:10,
0 replies
K
karix094
K
  • Newbie, joined since
  • Contributed 7 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
answered
Newbie

How do I prevent this number from reoccurring?

If my number is 38591,
then you can't get it?
1 reply
D
douwe_yntema
D
  • Senior Member, joined since
  • Contributed 667 posts on the community forums.
  • Started 57 threads in the forums
  • Answered 1 question
answered
Senior Member

That's the problem, with 5 digit numbers there is a chance they are not unique.
You could use the ID of the user, this is unique but easy to guess. You can set the startvalue of the id to e.g. 10000 to get a 5 digit number, but if e.g. I am number 10006, there is probably also number 10005 etc.

maybe better to use is UUD-short, but gives longer numbers

https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_uuid-short

Or use the UNIX timestamp at registration time
Edited by douwe_yntema on 15-10-2021 20:15,
0 replies
K
karix094
K
  • Newbie, joined since
  • Contributed 7 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
answered
Newbie

Quote

* After entering the number, it redirects to the page with information about the user to whom the number is assigned


If my number is 86420
and you enter it in the table
information from my profile will be displayed ::::
http://dt.info.pl/account.php?ref=4
http://dt.info.pl/profile.php?lookup=4

this is "account.php? ref = 4" and this is "profile.php? lookup = 4" this is the same file ... do you understand?

such a mini referral system
0 replies
— 5 months later —
K
karix094
K
  • Newbie, joined since
  • Contributed 7 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
answered
Newbie

So now I have a couple of options to choose from...
1. UUD-short.
2. UNIX timestamp at registration time.
3. Recently I thought about using a "hash" function for user_id.
E.g.:
In this case, I would use the "CRC32" algorithm
If my user_id = 1 is:
CRC32 hash for "1" is "6c300461"

Now I have to add another column in the database (next to user_id) to store this "unique number".

I have 3 questions:
1. What is the chance that the value "6c300461" will repeat itself?
2. Which option would you choose?
3. In what files and what to add or change in them, so that during registration and when adding a user in the administration panel, this number is saved in the database?
0 replies
F
Falk
F
Falk 131
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 11 questions
answered
Super Admin

1. Use that and always add the user_id as final number and you have zero chance.
2. Id do it more like ,
$secret_rand = rand(1000000, 9999999); // or time().
$secret_hash = substr(md5($secret_rand), 8, 8);
$secret_final = $secret_hash.$user_id;

3, Best is to create a user field that handles this.
0 replies
M
MathiasHU
M
https://fusion.bltfm.hu/
  • Junior Member, joined since
  • Contributed 48 posts on the community forums.
  • Started 3 threads in the forums
  • Answered 1 question
answered
Junior Member

A simple code
$rand_five_digit = rand(10000, 99999);
$result = dbquery("SELECT user_id, five_digit FROM ".DB_USERS." ");
while ($udata = dbarray($result)) {
   if ($rand_five_digit == $udata['five_digit']) {
      $rand_five_digit = rand(10000, 99999);
   }
}
echo $rand_five_digit;


Save to database
0 replies

Labels

Statistics

  • Views 0 views
  • Posts 7 posts
  • Votes 0 votes
  • Topic users 6 members

6 participants

F
F
Falk 131
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 11 questions
C
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
D
D
  • Senior Member, joined since
  • Contributed 667 posts on the community forums.
  • Started 57 threads in the forums
  • Answered 1 question
M
M
https://fusion.bltfm.hu/
  • Junior Member, joined since
  • Contributed 48 posts on the community forums.
  • Started 3 threads in the forums
  • Answered 1 question
V
V
  • Junior Member, joined since
  • Contributed 13 posts on the community forums.
  • Started 4 threads in the forums
K
K
  • Newbie, joined since
  • Contributed 7 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet