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

24 25 26 27 28 29 30 31 32 33 34
 $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 ";
dmorley's avatar
cleanup  
dmorley committed
35
     $message = "Pod:" . $_POST["domain"] . $_POST['domain'] . $_POST['username'] . $_POST['userurl'] . $_POST['comment'] . $_POST['rating'] . "\n\n";
36 37 38 39 40 41
     $headers = "From: ".$_POST["email"]."\r\n";
     @mail( $to, $subject, $message, $headers );    

     echo "Comment posted!";
     pg_free_result($result);
     pg_close($dbh);
42

root's avatar
root committed
43
?>