-
Notifications
You must be signed in to change notification settings - Fork 0
/
rate_movie.php
60 lines (55 loc) · 2.04 KB
/
rate_movie.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
require_once('auth.php')
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Rate Success</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link rel="icon" href="icons/fav.ico" type="image/x-icon">
<link rel="shortcut icon" href="icons/fav.ico" type="image/x-icon">
</head>
<body>
<div class="content">
<?php
require_once('menu.php'); menu();
?>
<h1>Rate Success</h1>
<?php
require_once('config.php');
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Get all results as UTF-8
mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'latin1', character_set_server = 'latin1'", $link)
or die(mysql_error());
//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
//Get all results as UTF-8
mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'latin1', character_set_server = 'latin1'", $link)
or die(mysql_error());
//put the value of the searchform in sdata
$rate=$_POST['rate'];
$movieid=$_POST['movie_id'];
$result = mysql_query('UPDATE rates SET rate = "'.$rate.'" WHERE user_id = '.$_SESSION['MEMBER_ID'].' AND movie_id = '.$movieid)
or die(mysql_error());
if (mysql_affected_rows()==0) {
$result = mysql_query("INSERT INTO rates (`movie_id`, `user_id` , `rate` ) VALUES ('$movieid', '".$_SESSION['MEMBER_ID']."', '".$rate."')");
echo '<br /><h3>You Rate it!</h3>';
echo '<h3>Thank you.</h3>';
}
else {
echo '<br /><h3>Your rate was updated!</h3>';
echo '<h3>Thank you.</h3>';
}
?>
</div>
<?php include "footer.php"; ?>
</body>
</html>