I want to get email address,hotel name and the rate value from the form and insert into rating table. when inserting data to rate table it should insert username of the email address from the user table.
here is the php code i tried.
if (!empty($_POST)) {
$userName = "";
$sql = "select name from user where email='$_POST[user]'";
$query1 = mysql_query($sql,$con);
while ($row = mysql_fetch_array($query1))
{
$userName = $row;
echo $userName;
}
$rest_name = $_POST['name'];
$user_name = $_POST['user'];
$rate = $_POST['Rate'];
$query = "INSERT INTO rates(rest_name,user,rate) values ('$_POST[name]','".$userName"','$_POST[Rate]')";
$query2 = mysql_query($query,$con);
$response["success"] = 1;
$response["message"] = "Rate Successfully Added!";
echo json_encode($response);
}
But it's not works. Can anyone help me?