<?php
$login=mysql_connect("localhost","wauhaha_smart",'asd123');
mysql_select_db("wauhaha_smart");

 date_default_timezone_set ("Singapore"); 
$date=date("d-m-Y", time());
$time=date("h:i:sa", time());



$result=mysql_query("SELECT * FROM userreview WHERE userID='".$_REQUEST['userID']."' and productID='".$_REQUEST['productID']."'");
			if(mysql_num_rows($result)>0){
				
				echo "Faild";
		
			}else{
			
					$str2 = "SELECT Max(reviewID) FROM userReview";



						
						$result3 = mysql_query ($str2,$login);
						list($result3)=mysql_fetch_array($result3);
						$rid = ++$result3;
						
						if($rid == "1")
						{
							$rid = "UR00000001";
						}	


			mysql_query("insert into userreview (reviewID,productID,userID,rating,comment,dateSubmit,timeSubmit)
					values('$rid','".$_REQUEST['productID']."','".$_REQUEST['userID']."','".$_REQUEST['rating']."','".$_REQUEST['comment']."','$date','$time')");
			
			echo "Done";
			}



?>