Advertisement
Guest User

Untitled

a guest
Jan 4th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <?php
  2. if(empty($_GET['id'])){
  3. session_start();
  4. $idProduct=$_SESSION['buttonkurcze'];
  5. $host="localhost";
  6. $db_user ="root";
  7. $db_password="";
  8. $db_name="exampledatabase";
  9. $idUser=$_SESSION['id'];
  10. //Create connection and select DB
  11. $connection= @new mysqli($host, $db_user, $db_password, $db_name);
  12.  
  13. if ($connection->connect_error) {
  14. die("Unable to connect database: " . $connection->connect_error);
  15. }
  16.  
  17. //get content from database
  18. //$query = $connection->query("INSERT INTO shoppingcart VALUES (NULL, '$idUser', '$idProduct')");
  19. if ($connection->query("INSERT INTO shoppingcart VALUES (NULL, '$idUser', '$idProduct')")) {
  20. //$query="INSERT INTO shoppingcart VALUES (NULL, '$idUser', '$idProduct')";
  21. //$query_result=mysqli_query($connection, $query);
  22. }
  23.  
  24. $connection->close();
  25. } else {
  26. echo 'error';
  27. }
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement