Advertisement
Guest User

Untitled

a guest
Jun 10th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. <?php
  2. //// usually dbconnect.php situated in /includes/dbconnect.php
  3. $dbhost = 'localhost';
  4. $dbuser = 'xxxxxx';
  5. $dbpass = 'xxxxxx';
  6. $dbname = "xxxxxx";
  7.  
  8.  
  9. $conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
  10. if(! $conn ) {
  11. die('Could not connect: ' . mysql_error());
  12. }else{
  13. echo "connected";
  14. }
  15. // End of file
  16.  
  17. // create_user.php situated at /create_user.php
  18. if (empty($_POST)=== FALSE){
  19. $myusername = $_POST['myusername'];
  20. $mypassword = $_POST['mypassword'];
  21.  
  22.  
  23.  
  24. if($mypassword !== $_POST['mypassword_check']){
  25. echo "Passwords do not match.";
  26. }
  27. else{
  28.  
  29. $sql = "INSERT INTO users(user_email, user_pass, active) VALUES ('$myusername', '$mypassword', '1')";
  30. $retval = mysqli_query( $conn, $sql );
  31. if($retval){
  32. echo "New record created successfully";
  33. } else {
  34. echo "Error: " . $sql . "<br>" . mysqli_error($conn);
  35. }
  36.  
  37. }
  38. }else{
  39. echo "How did you even get here?";
  40. }
  41.  
  42.  
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement