PHP Classes

File: example1c_add.php

Recommend this page to a friend!
  Classes of Manish Khanchandani   Reviews   example1c_add.php   Download  
File: example1c_add.php
Role: Example script
Content type: text/plain
Description: Example
Class: Reviews
Store and retrieve reviews of products in MySQL
Author: By
Last change:
Date: 14 years ago
Size: 3,127 bytes


Class file image Download
if($_POST['MM_Insert']==1) {
    try {
// including rating class
$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'];
$data['uniqueip']=="1") {
$count = $Reviews->checkRatingUniqueIp($data);
$count>0) throw new Exception("Duplicate Ip");
$data['uniqueuser']=="1") {
$count = $Reviews->checkRatingUniqueUser($data);
$count>0) throw new Exception("Duplicate User");
$rating_id = $Reviews->phpinsert('xoriant_reviews_ratings', 'rating_id', $data);
header("Location: example1c.php?item_id=".$_GET['item_id']);
    } catch (
exception $e) {
$errorMessage = $e->getMessage();
$message = $errorMessage;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Add Review</title>

<h1>Add Review </h1>
<p><a href="example1c.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>Review Description: <br />
    <textarea name="review_description" cols="35" rows="5" id="review_description"><?php echo $_POST['review_description']; ?></textarea>
  <p>Pros: <br />
      <textarea name="pros" cols="35" rows="5" id="pros"><?php echo $_POST['pros']; ?></textarea>
  <p>Cons: <br />
      <textarea name="cons" cols="35" rows="5" id="cons"><?php echo $_POST['cons']; ?></textarea>
  <p>&nbsp; </p>
  <?php for($i=1;$i<=10;$i++) { ?>
<input name="rating" type="radio" value="<?php echo $i; ?>" <?php if($_POST['rating']==$i) echo ' checked'; ?> />
    <?php } ?>
    <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="user_id" type="hidden" id="user_id" value="1" />
<p>&nbsp; </p>