无法使用php插入localhost(mysql)数据库
我无法将注册表数据插入本地主机数据库 我正在使用xampp服务器,运行mysql 5、PHP7和apache2。我提供了可以将表单数据插入数据库的代码。数据库已连接。我也重新启动了xampp服务器,但它显示了相同的问题无法使用php插入localhost(mysql)数据库,php,html,ajax,Php,Html,Ajax,我无法将注册表数据插入本地主机数据库 我正在使用xampp服务器,运行mysql 5、PHP7和apache2。我提供了可以将表单数据插入数据库的代码。数据库已连接。我也重新启动了xampp服务器,但它显示了相同的问题 <?php $active='Account'; include("includes/header.php"); ?> //html form with correct name values <?php if(isset($_POS
<?php
$active='Account';
include("includes/header.php");
?>
//html form with correct name values
<?php
if(isset($_POST['register'])){
$c_name = $_POST['c_name'];
$c_email = $_POST['c_email'];
$c_pass = $_POST['c_pass'];
$c_country = $_POST['c_country'];
$c_city = $_POST['c_city'];
$c_contact = $_POST['c_contact'];
$c_address = $_POST['c_address'];
$c_image = $_FILES['c_image']['name'];
$c_image_tmp = $_FILES['c_image']['tmp_name'];
move_uploaded_file($c_image_tmp,"customer/customer_images/$c_image");
$insert_customer = "insert into customers (customer_name,customer_email,customer_pass,customer_country,customer_city,customer_contact,customer_address,customer_image,customer_ip) values ('$c_name','$c_email','$c_pass','$c_country','$c_city','$c_contact','$c_address','$c_image','$c_ip')";
$result = mysqli_query($con,$insert_customer);
$sel_cart = "select * from cart where ip_add='$c_ip'";
$run_cart = mysqli_query($con,$sel_cart);
$check_cart = mysqli_num_rows($run_cart);
if($check_cart>0){
$_SESSION['customer_email']=$c_email;
echo "<script>alert('User is already present');</script>";
echo "<script>window.open('checkout.php','_self')</script>";
}else{
$_SESSION['customer_email']=$c_email;
echo "<script>alert('You have been Registered Sucessfully')</script>";
echo "<script>window.open('index.php','_self')</script>";
}
}
?>
//具有正确名称值的html表单
选中您定义的$con变量。连接变量应该在页面上定义,并使用mysqli函数调用
$result=mysqli\u查询($con,$insert\u客户) 您对SQL注入非常开放。由于您使用的是mysqli,请利用和。这将解决可能出现的任何令人讨厌的引用问题。当查询无法按预期工作时,您需要显式检查以找出原因。为什么将此标记为“ajax”?用于此的HTML在哪里?