Guest User

Untitled

a guest
Jan 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. session_start();
  2.  
  3. $servername = "localhost";
  4. $username = "root";
  5. $password = "root";
  6. $dbname = "somedatabase";
  7.  
  8. try {
  9.  
  10. $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
  11. // set the PDO error mode to exception
  12. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  13.  
  14. // prepare sql and bind parameters
  15. $stmt = $conn->prepare("INSERT
  16.  
  17. INTO
  18.  
  19. patients
  20.  
  21. ( comments )
  22.  
  23. VALUES
  24.  
  25. ( :comment )
  26.  
  27. WHERE
  28.  
  29.  
  30. unique_id = :unique_id
  31.  
  32. ");
  33.  
  34.  
  35. $stmt->bindParam( ':comment', $comment );
  36. $stmt->bindParam( ':unique_id', $unique_id );
  37.  
  38.  
  39.  
  40. $comment = $_POST[ 'comment' ];
  41. $unique_id = $_SESSION[ 'unique_id' ];
  42.  
  43.  
  44. $stmt->execute();
  45.  
  46.  
  47.  
  48.  
  49.  
  50. //header('Location: newMedicine.php');
  51.  
  52. }
  53. catch(PDOException $e)
  54. {
  55. echo "Error: " . $e->getMessage();
  56. }
  57. $conn = null;
  58.  
  59. $comment = $_POST[ 'comment' ];
  60. $unique_id = $_SESSION[ 'unique_id' ];
Add Comment
Please, Sign In to add comment