I am beginner in jquery "actually its my first code". i am working on stars rating system, the jquery part worked perfectly and it returns the value of rate. But when it comes to php code it did! i want to pass (rate variable) from (index.php) to (rate.php) file in order to insert it into (rate) table. please help me
Index.php:
<!DOCTYPE html class="ng-scope" ng-app="">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="js/ca-pub-2074772727795809.js" type="text/javascript" async=""></script>
<script src="js/analytics.js" async=""></script>
</head>
<body>
<h1>please Rate:</h1>
<script>
$(function(){
$(".stars").on("click", function(){
var rate = $(this).val();
alert(rate);
});
});
</script>
<fieldset id='starset' class="rating" name="star">
<input class="stars" type="radio" id="star5" name="rating" value="5" />
<label class = "full" for="star5" title="Awesome - 5 stars"></label>
<input class="stars" type="radio" id="star4" name="rating" value="4" />
<label class = "full" for="star4" title="Pretty good - 4 stars"></label>
<input class="stars" type="radio" id="star3" name="rating" value="3" />
<label class = "full" for="star3" title="Meh - 3 stars"></label>
<input class="stars" type="radio" id="star2" name="rating" value="2" />
<label class = "full" for="star2" title="Kinda bad - 2 stars"></label>
<input class="stars" type="radio" id="star1" name="rating" value="1" />
<label class = "full" for="star1" title="Sucks big time - 1 star"></label>
</fieldset>
</body>
rate.php:
<?php
$connect=mysql_connect("localhost","root","");
$db=mysql_select_db("HWP",$connect);
$rate=$_POST['val']
if (isset($rate) && !empty($rate))
{
$query1 = mysql_query("select rate_id FROM rate WHERE Rate_cust_id= 1");
$f1 = mysql_num_rows($query1);
if (mysql_num_rows($query1) > 0)
{
echo $f1['rate_id'];
}
else
{
$query2= mysql_query("insert into rate ( rate_value, rate_cust_id , rate_hw_id) VALUES ($rate, 4 , 2); ");
if ($query2) {
echo "0";
}
}
}
?>