Advertisement
Guest User

Insert Into_mysql

a guest
Jul 4th, 2018
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. <?php
  2.  
  3. $host = 'localhost';
  4. $user = 'root';
  5. $pass = '';
  6. // specifically database name
  7. $db = 'users';
  8.  
  9. $link = mysqli_connect($host, $user, $pass, $db);
  10. if (mysqli_connect_error()) {
  11. die ("There was an error connecting to the database");
  12. }
  13.  
  14. $query = "INSERT INTO `example` (`email`, `password`) VALUES ('charles@gmail.com', 'ilovemydad')";
  15. mysqli_query($link, $query);
  16.  
  17. // if targeting the query put the table name.
  18. // query means command
  19. $query = "SELECT * FROM example";
  20. if ($result = mysqli_query($link, $query)) {
  21. $row = mysqli_fetch_array($result);
  22. echo "Your email is ".$row['email']." and your password is ".$row['password'];
  23. }
  24.  
  25.  
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement