我将数据从android发送到php然后发送到数据库,但我的插入查询无法正常工作。我找不到问题所在它总是打印“无法注册”。我已经检查了我的表数据库以及我的变量是从android.Below正确发布的代码。
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";
}