简体   繁体   中英

Get Unique System ID using php

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.

您可以将openssl_random_pseudo_bytesbin2hex用于安全的随机字符串。

echo bin2hex(openssl_random_pseudo_bytes(9));

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>

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM