Guest User

Untitled

a guest
Jul 19th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.48 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include("rmb.php");
  4.  
  5. $cxn = mysqli_connect($host,$user,$passmilah,$dbase)
  6.     or die("Query died: connect");
  7.  
  8. $func = $_GET['func']; 
  9. $func($cxn);
  10.  
  11. function salt($length)
  12. {
  13.     // Assign strings to variables
  14.     $lc = 'abcdefghijklmnopqrstuvwxyz'; // lowercase
  15.     $uc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; // uppercase
  16.     $nr = '1234567890'; // numbers
  17.     $sp = '^@*+-+%()!?'; //special characters
  18.     $chars = $lc.$up.$nr.$sp;
  19.    
  20.     // Length of character list
  21.     $chars_length = (strlen($chars)1);
  22.     // Start our string
  23.     $string = $chars{rand(0, $chars_length)};
  24.     // Generate random string
  25.     for ($i = 1; $i < $length; $i = strlen($string))
  26.     {
  27.         // Take random character from our list
  28.         $random = $chars{rand(0, $chars_length)};
  29.         // Make sure the same two characters don’t appear next to each other
  30.         if ($random != $string{$i1}) $string .= $random;
  31.     }
  32.     return $string;
  33. }
  34.  
  35. function login($cxn)
  36. {
  37.    
  38. }
  39.  
  40. function register($cxn)
  41. {
  42.     $username = mysqli_real_escape_string($_GET['fusername']);
  43.     $sql = "SELECT username FROM user WHERE username = '$username' ";
  44.     $result = mysqli_query($cxn,$sql)
  45.         or die(mysqli_error($cxn));
  46.     $num = mysqli_num_rows($result);
  47.    
  48.     if($num > 0) //if the username exists already                              
  49.     {
  50.         exit();
  51.     }
  52.     else //adding the new user to the database
  53.     {
  54.         $password = md5($_GET['fpassword']);
  55.         $salt = salt(5);
  56.         $const = "hy7";
  57.         $password .= $salt;
  58.         $password .= $const;
  59.         echo $password
  60.        
  61.     }
  62. }
Add Comment
Please, Sign In to add comment