-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlike.php
32 lines (28 loc) · 859 Bytes
/
like.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
session_start();
$DB_DSN = 'localhost';
$DB_USER = 'root';
$DB_PASSWORD = '';
$DB_NAME = 'camagru';
//connect to the newly created database
try {
$conn = new PDO("mysql:host=$DB_DSN;dbname=$DB_NAME", $DB_USER, $DB_PASSWORD);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
// INSERT IGNORE INTO viewstats (user1,user2) VALUES (9,10)
try{
$sql = $conn->prepare(" INSERT IGNORE INTO likes (user1,user2) VALUES (:userID,:viewersID)");
$sql->bindParam(':viewersID', $_GET['uid']);
$sql->bindParam(':userID', $_SESSION['id']);
$sql->execute();
header('Location: history.php');
}catch(Exception $e)
{
echo 'Error: ' . $e->getMessage();
}
?>