Advertisement
nGenchev

db_cli.php

Dec 25th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None | 0 0
  1. <?php
  2. $host = 'localhost';
  3. $user = 'root';
  4. $pass = '';
  5.  
  6. try
  7. {
  8.     $conn = mysqli_connect($host, $user, $pass, 'test');
  9. }
  10. catch (Exception $e)
  11. {
  12.     echo $e->getMessage();
  13. }
  14.  
  15. if($conn)
  16. {
  17.     echo "Username: ";
  18.     $get_user = fgets(STDIN);
  19.     echo "Password: ";
  20.     $get_pass = fgets(STDIN);
  21.     echo "Email: ";
  22.     $get_email = fgets(STDIN);
  23.    
  24.     $sql = "INSERT INTO users (`user_NAME`, `user_PASS`, `user_EMAIL`) VALUES ('{$get_user}', '{$get_pass}', '{$get_email}')";
  25.     $sql = mysqli_query($conn, $sql) or die("Problem s bd: ".mysqli_errno($conn));
  26.     if($sql) echo "Uspeshno dobavi nov potrebitel s ime: {$get_user}";
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement