saverating.php 1.1 KB
Newer Older
root's avatar
root committed
1
<?php
2
if (!$_POST['username']){
noplanman's avatar
noplanman committed
3
  die("no username given");
root's avatar
root committed
4 5
}
if (!$_POST['userurl']){
noplanman's avatar
noplanman committed
6
  die("no userurl given");
root's avatar
root committed
7 8
}
if (!$_POST['domain']){
noplanman's avatar
noplanman committed
9
  die("no pod domain given");
root's avatar
root committed
10 11
}
if (!$_POST['comment']){
noplanman's avatar
noplanman committed
12
  die("no comment");
root's avatar
root committed
13 14
}
if (!$_POST['rating']){
noplanman's avatar
noplanman committed
15
  die("no rating given");
root's avatar
root committed
16
}
17 18 19

require_once __DIR__ . '/../config.php';

dmorley's avatar
cleanup  
dmorley committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
  die("Error in connection: " . pg_last_error());
}
$sql = "INSERT INTO rating_comments (domain, comment, rating, username, userurl) VALUES($1, $2, $3, $4, $5)";
$result = pg_query_params($dbh, $sql, array($_POST['domain'], $_POST['comment'], $_POST['rating'], $_POST['username'], $_POST['userurl']));
if (!$result) {
  die("Error in SQL query: " . pg_last_error());
}
$to = $adminemail;
$subject = "New rating added to poduptime ";
$message = "Pod:" . $_POST["domain"] . $_POST['domain'] . $_POST['username'] . $_POST['userurl'] . $_POST['comment'] . $_POST['rating'] . "\n\n";
$headers = "From: ".$_POST["email"]."\r\n";
@mail( $to, $subject, $message, $headers );    
echo "Comment posted!";
pg_free_result($result);
pg_close($dbh);