1

I want client system's unique id for registering my app.

My Method (or idea):

  1. I give a key (key1) to my client when he purchase my application

  2. After he installs my application on his local server, I want to verify that installation.so he want to submit a form

  3. after receiving that information, I want to store that information and update his local database.

    1. my server database 'installations' table structure : name(empty) , email(empty) , address(empty) , key1 , key2 , unique_id(empty) , status(0)

      if key1 currect and status == 0, his informations with unique_id save in installations table & status set to 1 & his local database will update with key1 and key2.

      if key1 currect and status == 1 (re-installing time), then his local machine unique_id and installations table unique_id will check. if equal, his local database will update with key1 and key2.

      if not currect, his local database will update with key1('key not valid') and key2('key not valid').

  4. if local database verification table values (key1 and key2) not 'key not valid' then application will work.

Client form:

<?php
$unique_id = "i want unique system id here";
?>
<form action="http://www.example.com/verifiy.php" method="post">
    <p>
        <label>Name</label>
        <input type="text" name="name" />
    </p>
    <p>
        <label>Email</label>
        <input type="text" name="email" />
    </p>
    <p>
        <label>Phone</label>
        <input type="text" name="phone" />
    </p>
    <p>
        <label>Activation key</label>
        <input type="text" name="name" />
    </p>
    <p class="hidden">
        <input type="text" name="unique_id" value="<?php echo $unique_id; ?>" />
    </p>
    <input type="submit" />
</form>

When client submit this form, i want save all informations with system unique id on my server and i will give him to a key.

please help me, how can i get client system's unique id? sorry for my bad english. Thanks.

Maxime Lorant
  • 34,607
  • 19
  • 87
  • 97
SAFEER N
  • 1,157
  • 2
  • 17
  • 30
  • 1
    What you mean by "unique_id"? Do you create it or you mean something else? – Touch Sep 15 '13 at 09:06
  • i want unique id inside $unique_id variable. – SAFEER N Sep 15 '13 at 09:08
  • Look at http://stackoverflow.com/questions/18804079/get-the-response-from-server-in-json-format-without-using-database/18804450#18804450 and instead of `rand()` use Jordan Doyle suggestion to generate an random string. – Michal Sep 15 '13 at 09:09
  • you will probably be storing the data in a db? then use its own primary key –  Sep 15 '13 at 09:12
  • possible duplicate of [how to identify remote machine uniquely in php?](http://stackoverflow.com/questions/1198094/how-to-identify-remote-machine-uniquely-in-php) – Quentin Sep 15 '13 at 09:13

3 Answers3

1

You can use openssl_random_pseudo_bytes and bin2hex for a secure, random string.

echo bin2hex(openssl_random_pseudo_bytes(9));
Jordan Doyle
  • 2,976
  • 4
  • 22
  • 38
0

Make use of uniqid function in PHP.

<?php
/* A uniqid, like: 4b3403665fea6 */
printf("uniqid(): %s\r\n", uniqid());

Your code..

<?php
$unique_id = uniqid(); // I have added it here.
?>
<form action="http://www.example.com/verifiy.php" method="post">
    <p>
        <label>Name</label>
        <input type="text" name="name" />
    </p>
    <p>
        <label>Email</label>
        <input type="text" name="email" />
    </p>
    <p>
        <label>Phone</label>
        <input type="text" name="phone" />
    </p>
    <p class="hidden">
        <input type="text" name="unique_id" value="<?php echo $unique_id; ?>" />
    </p>
    <input type="submit" />
</form>
Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126
  • Note: if you might happen to generate two values at the same microsecond it wont be unique since `uniqid` is based off of time. – Jordan Doyle Sep 15 '13 at 09:15
  • Well maybe. But that is highly unlikely. – Shankar Narayana Damodaran Sep 15 '13 at 09:18
  • 1
    @JordanDoyle `uniqid`’s values do not only incorporate the time but also the state of an PRNG. So even in the unlikely case the microseconds of two sequential calls are identical the random part is most likely not identical. – Gumbo Sep 15 '13 at 10:08
0

Use below 2 steps to generate unique data about visitor..

  1. Use $_SERVER['REMOTE_ADDR'] will give you IP Address of user who is viewing this page.

  2. Use HTML5 Geolocation API to get location of User.

Generate a unique id based on above 2 datas

<script>
   var x=document.getElementById("demo");
   function getLocation()
   {
     if (navigator.geolocation)
       {
         navigator.geolocation.getCurrentPosition(showPosition);
       }
     else{x.innerHTML="Geolocation is not supported by this browser.";}
   }
  function showPosition(position)
  {
   //Get latitude & longitude from position
   x.innerHTML="Latitude: " + position.coords.latitude + 
   "<br>Longitude: " + position.coords.longitude; 
   }
  </script>
Kailash Ahirwar
  • 771
  • 3
  • 14
  • I don't know much about the geolocation thing but here are some questions. What if I am on campus(university) and using their computers. Won't my IP address be like hundreds of other people(students). And doesn't geolocation ask the user for permission? What if I denied it. Will I have a "unique_id"? Suppose I accepted the geolocation thing, if the other hundred accept too, won't we have the same "unique_id"? – Touch Sep 15 '13 at 10:48
  • Another way is to store a cookie file on client's system & store a unique id in cookie. Whenever client will open your web page try to authenticate using value stored in the cookie. But the problem with this approach is that if client's deletes the cookie. – Kailash Ahirwar Sep 16 '13 at 13:24