Advertisement
Guest User

Untitled

a guest
May 9th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. <?php
  2. $uname = "root";
  3. $pass = "root";
  4. $host = "localhost";
  5. $dbname = "kontaktform";
  6.  
  7. $username = $_POST['Namn'];
  8. $email = $_POST['Emailadress'];
  9. $comment = $_POST['inlagg'];
  10.  
  11. $connection = new mysqli($host, $uname, $pass, $dbname);
  12.  
  13. if ( $connection -> connect_error )
  14. {
  15. die (" Connection failed : ". $connection . connect_error ) ;
  16. }
  17. echo " Connection worked .";
  18.  
  19. $sql = "INSERT INTO users (namn, epost, kommentar)
  20. VALUES ('$username', '$email', '$comment')";
  21.  
  22. if ($connection ->query($sql) === TRUE) {
  23. echo "worked";
  24. }
  25. else {
  26. echo "try again". $sql. "<br>". $connection->error;
  27. }
  28. $connection->close();
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement