Advertisement
Guest User

Untitled

a guest
Oct 8th, 2016
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. include_once('assets/inc/db_login.inc');
  2. session_start();
  3.  
  4. function sql_entry($user,$pass,$phone,$points){
  5.  
  6. //do not touch anything beyond this part
  7. $conn = mysqli_connect(DB_HOST,DB_USERNAME,DB_PASSWORD,DB_NAME);
  8.  
  9. //error catcher for connection failure
  10. if($conn->connect_error){
  11. die("Connection failed: " . $conn->connect_error);
  12. }
  13.  
  14. date_default_timezone_set('America/Chicago');
  15.  
  16. //grabs the time
  17. $time = date('H:i:s');
  18. //$time = $time->format();
  19. $date = date('Y-m-d');
  20. //$date = $date->format();
  21.  
  22. //clean themmmmmm!
  23. $clean_user = mysqli_real_escape_string($conn, $user);
  24. $clean_pass = mysqli_real_escape_string($conn, $pass);
  25. $clean_phone = mysqli_real_escape_string($conn, $phone);
  26. $clean_points = mysqli_real_escape_string($conn, $points);
  27.  
  28. //prepare queries
  29. $verification = "SELECT * FROM ".DB_TBL."WHERE phone =".$clean_phone;
  30. $verification_result = mysqli_query($conn,$verification); //run query to validate user
  31.  
  32. $count = mysqli_num_rows($verification_result); //
  33.  
  34. //error catcher for non-existing username or wrong user/pass
  35. if($count < 1){
  36. $account_registration = "INSERT INTO ".DB_TBL." (username,password,register_date,phone,points,notes) VALUES ('$clean_user','$clean_pass','$date','$clean_phone','$clean_points','')";
  37. $registration_result = mysqli_query($conn,$account_registration);
  38. mysqli_close($conn);
  39. return 1;
  40. }
  41. else
  42. mysqli_close($conn);
  43. return 0;
  44. }
  45.  
  46. //here's the other variables for login (all are correct, i have triple checked them already countless times)
  47.  
  48. <?php
  49.  
  50. define ("DB_HOST", "127.0.0.1");
  51. define ("DB_USERNAME", "root");
  52. define ("DB_PASSWORD", "ragnarok");
  53. define ("DB_NAME", "houseofvbi");
  54. define ("DB_TBL", "users");
  55.  
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement