Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('dbconfig.php');
- class favorite {
- public $servername;
- public $username;
- public $password;
- public $db_name;
- public function __construct(){
- $this->servername = "localhost";
- $this->db_name = "my_cdefrancesco";
- $this->username = "";
- $this->password = "";
- }
- public function runQuery($sql){
- $stmt = $this->conn->prepare($sql);
- return $stmt;
- }
- public function insertFavorite($user_id, $artwork_id){
- $conn = new mysqli($this->servername, $this->username, $this->password, $this->db_name);
- if ($conn->connect_error) {
- print ('si è verificato un errore, si prega di riprovare');
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "INSERT INTO ivisits (user_id, artwork_id) VALUES ($user_id, '$artwork_id')";
- if ($conn->query($sql) === TRUE) {
- //echo "New record created successfully";
- $message = "opera aggiunta con successo";
- print ($message);
- } else {
- echo "si è verificato un errore, si prega di riprovare";
- //echo "Error: " . $sql . "<br>" . $conn->error;
- }
- $conn->close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement