Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. <?php
  2. $dsn = '';
  3. $user = '';
  4. $password = '';
  5.  
  6. try {
  7. $dbh = new PDO($dsn, $user, $password);
  8. } catch (PDOException $e) {
  9. echo 'Connection failed: ' . $e->getMessage();
  10. }
  11. ?>
  12.  
  13.  
  14.  
  15. <?php
  16. require 'mysqli_connect.php';
  17. if(isset($_POST['submit']) && !empty($_POST['submit'])){
  18.  
  19. $sth = $dbh->prepare('INSERT INTO test_table(comment) VALUES(?);');
  20. $comment = $_POST['comment'];
  21. $sth->execute(Array($comment));
  22. }
  23. ?>
  24.  
  25. <form action = "<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>" method = "post">
  26. <p>Comment</p>
  27. <textarea name= "comment" rows="6" cols="50"></textarea><br />
  28. <input type="submit" name= "submit" value="submit" id = "submit">
  29. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement