Advertisement
Guest User

Untitled

a guest
Jul 6th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $db_hostname = 'localhost';
  4. $db_database = 'hewden1';
  5. $db_username = 'root';
  6. $db_password = '';
  7. $db_server = mysql_connect($db_hostname, $db_username, $db_password)
  8. or die("Unable to connect to MySQL: " . mysql_error());
  9. mysql_select_db($db_database)
  10. or die("Unable to select database: " . mysql_error());
  11.  
  12. $num0 = (rand(10,100));
  13. $num1 = date("Ymd");
  14. $num2 = (rand(100,1000));
  15. $num3 = time();
  16. $randnum = $num0 . $num1 . $num2 . $num3;
  17.  
  18.  
  19. $sql="INSERT INTO supplier_session (session_number)
  20. VALUES ('$randnum')";
  21.  
  22. $result = mysql_query($sql);
  23. ?>
  24.  
  25. $randnum = rand(1111111111,9999999999);
  26.  
  27. <?php
  28.  
  29. for ($randomNumber = mt_rand(1, 9), $i = 1; $i < 10; $i++) {
  30. $randomNumber .= mt_rand(0, 9);
  31. }
  32.  
  33. var_dump($randomNumber); //eg. string(10) "9152676628"
  34.  
  35. SIGNED INT - 2147483647
  36. UNSIGNED INT - 4294967295
  37.  
  38. SIGNED BIGINT - 9223372036854775807
  39. UNSIGNED BIGINT - 18446744073709551615
  40.  
  41. $MIN_SESSION_ID = 1000000000;
  42. $MAX_SESSION_ID = 9999999999;
  43.  
  44. $randId = mt_rand($MIN_SESSION_ID, $MAX_SESSION_ID);
  45.  
  46. echo $randId;
  47.  
  48. private string generaterandomnumber()
  49. {
  50. string Rand1 = RandomString(8);
  51. string Rand2 = RandomString(8);
  52. docNum = Rand1 + "-" + Rand2;
  53. MD5 md5 = new MD5CryptoServiceProvider();
  54. md5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(docNum));
  55.  
  56. //get hash result after compute it
  57. byte[] result = md5.Hash;
  58.  
  59. StringBuilder strBuilder = new StringBuilder();
  60. for (int i = 0; i < result.Length; i++)
  61. {
  62. //change it into 2 hexadecimal digits
  63. //for each byte
  64. strBuilder.Append(result[i].ToString("x2"));
  65. }
  66. return strBuilder.ToString();
  67. }
  68.  
  69. $x = 10; // Amount of digits
  70. $min = pow(10,$x);
  71. $max = pow(10,$x+1)-1);
  72. $value = rand($min, $max);
  73.  
  74. <?php
  75. echo mt_rand();
  76. ?>
  77.  
  78. function random_num ($len)
  79. {
  80. $ch = "0123456789";
  81. $l = strlen ($ch) - 1;
  82. $str = "";
  83. for ($i=0; $i < $len; $i++)
  84. {
  85. $x = rand (0, $l);
  86. $str .= $ch[$x];
  87. }
  88. return $str;
  89. }
  90.  
  91. unset($num0, $num1, $num2, $num3);
  92. $num0 = (rand(10,100));
  93. $num1 = date("Ymd");
  94. $num2 = (rand(100,1000));
  95. $num3 = time();
  96. $randnum = $num0 . $num1 . $num2 . $num3;
  97.  
  98. <?php
  99.  
  100. function generateRandomNumber($length = 10) {
  101. $number = '1234567890';
  102. $numberLength = strlen($number);
  103. $randomNumber = '';
  104. for ($i = 0; $i < $length; $i++) {
  105. $randomNumber .= $number[rand(0, $numberLength - 1)];
  106. }
  107. return $randomNumber;
  108. }
  109.  
  110. echo generateRandomNumber();
  111.  
  112. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement