I am sending data from android to php and then to database but my insert query is not working.I can't find what the problem is it always print " could not register ".I have checked my table database as well as my variable are correctly posting from android.Below is the code.
if (isset($_POST)){
define('HOST','127.0.0.1');
define('USER','root');
define('PASS','');
define('DB','medicine'); // database
$con = mysqli_connect(HOST,USER,PASS,DB) or die('Unable to Connect');
$email = $_POST['email'];
$name = $_POST['name'];
$phone= $_POST['phone'];
$password=$_POST['password'];
$cnic=$_POST['cnic'];
$address=$_POST['address'];
// Variables are successfully posted
$email = mysql_real_escape_string($email);
$name = mysql_real_escape_string($name);
$phone = mysql_real_escape_string($phone);
$password = mysql_real_escape_string($password);
$cnic = mysql_real_escape_string($cnic);
$address = mysql_real_escape_string($address);
$sql = "INSERT INTO userregister (email,name,phone,password,cnic,address) VALUES ('$email','$name','$phone','$password','$cnic','$address')";
if(mysqli_query($con,$sql))
{
echo "Successfully Registered";
}
else
{
echo "Could not register";
}