<?php
if($_POST['MM_Insert']==1) {
try {
// including rating class
include_once('Xoriant_Reviews.php');
$Reviews = new Xoriant_Reviews();
$data['user_id'] = $_POST['user_id'];
$data['item_id'] = $_POST['item_id'];
$data['rating'] = $_POST['rating'];
$data['rating_ip'] = $_POST['rating_ip'];
$data['rating_date'] = $_POST['rating_date'];
$data['uniqueip'] = $_POST['uniqueip'];
$data['uniqueuser'] = $_POST['uniqueuser'];
$data['review_title'] = $_POST['review_title'];
$data['review_description'] = $_POST['review_description'];
$data['pros'] = $_POST['pros'];
$data['cons'] = $_POST['cons'];
$Reviews->validateData($data);
if($data['uniqueip']=="1") {
$count = $Reviews->checkRatingUniqueIp($data);
if($count>0) throw new Exception("Duplicate Ip");
}
if($data['uniqueuser']=="1") {
$count = $Reviews->checkRatingUniqueUser($data);
if($count>0) throw new Exception("Duplicate User");
}
$rating_id = $Reviews->phpinsert('xoriant_reviews_ratings', 'rating_id', $data);
header("Location: example1b.php?item_id=".$_GET['item_id']);
exit;
} catch (exception $e) {
$errorMessage = $e->getMessage();
$message = $errorMessage;
}
}
?>
<!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=iso-8859-1" />
<title>Add Review</title>
</head>
<body>
<h1>Add Review </h1>
<p><a href="example1a.php?item_id=<?php echo $_GET['item_id']; ?>">Back</a></p>
<form id="form1" name="form1" method="post" action="">
<?php echo $message; ?>
<p>Review Title:
<input name="review_title" type="text" id="review_title" value="<?php echo $_POST['review_title']; ?>" />
</p>
<p>Review Description: <br />
<textarea name="review_description" cols="35" rows="5" id="review_description"><?php echo $_POST['review_title']; ?></textarea>
</p>
<p>Rating:
<?php for($i=1;$i<=10;$i++) { ?>
<input name="rating" type="radio" value="<?php echo $i; ?>" <?php if($_POST['rating']==$i) echo ' checked'; ?> />
<?php } ?>
</p>
<p>
<input type="submit" name="Submit" value="Submit" />
<input name="item_id" type="hidden" id="item_id" value="<?php echo $_GET['item_id']; ?>" />
<input name="MM_Insert" type="hidden" id="MM_Insert" value="1" />
<input name="uniqueuser" type="hidden" id="uniqueuser" value="0" />
<input name="uniqueip" type="hidden" id="uniqueip" value="0" />
<input name="rating_date" type="hidden" id="rating_date" size="25" value="<?php echo date('Y-m-d H:i:s'); ?>" />
<input name="rating_ip" type="hidden" id="rating_ip" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>" />
<input name="cons" type="hidden" id="cons" value="" size="35" />
<input name="pros" type="hidden" id="pros" value="" size="35" />
<input name="user_id" type="hidden" id="user_id" value="1" />
</p>
</form>
<p> </p>
</body>
</html>
|