Search code examples
phphelper

Error generating referral link in php


I would like to create a referral link but I had a problem I would like each link to be unique but I did not know how to do it and put a rand line something like this

  <br>
 <center>Реферальная ссылка: 
<input value="http://example .com/?ref=<?php
    if ($a > $b) {
       echo rand() . "\n";
    } elseif ($a == $b) {
        echo rand() . "\n";
    } else {
        echo rand(5, 15);
    }
    ?>" " onClick="select()" size="30" type="text"></center>
    <br />

What should I do to make the referral link unique to each user?


Solution

  • php has a function called uniqid documentation can be found Here. The ID is unique as it..:

    Gets a prefixed unique identifier based on the current time in microseconds.

    Read through the docs and see what you can come up with seems like a very interesting function, it has some examples that imagine you could fairly easily implement to achieve your goals, it does seem like it has some flaws but people have somewhat addressed them in the documentation also, good luck!