gpt4 book ai didi

javascript - 当我刷新页面时,数据自动存储在数据库中

转载 作者:行者123 更新时间:2023-11-30 22:15:37 26 4
gpt4 key购买 nike

我用 php 制作了注册页面。当我在填写所有内容后注册一个用户时,数据已正确存储在数据库中,但之后如果我刷新注册页面而不填写任何内容,那么最近的用户数据将再次存储在数据库中。为什么会这样?最后的脚本也不起作用

下面是我的php代码

<?php 

if (isset($_POST['register'])) {

$ip = getIp();

$c_name = $_POST['c_name'];
$c_email = $_POST['c_email'];
$c_pass = $_POST['c_pass'];
$c_image = $_FILES['c_image']['name'];
$c_image_tmp = $_FILES['c_image']['tmp_name'];
$c_country = $_POST['c_country'];
$c_city = $_POST['c_city'];
$c_contact = $_POST['c_contact'];
$c_address = $_POST['c_address'];

move_uploaded_file($c_image_tmp, "customer/customer_images/$c_image");

$insert_c = "insert into customers (customer_ip,customer_name,customer_email,customer_pass,customer_country,customer_city,customer_contact,customer_address,customer_image) values ('$ip','$c_name','$c_email','$c_pass','$c_country','$c_city','$c_contact','$c_address','$c_image')";
}
$run_c = mysqli_query($con, $insert_c);

$sel_cart = "select * from cart where ip_add='$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('Accound has been created successfully')</script>";
echo "<script>window.open('customer/my_accont.php'.'_self')</script>";
}
else {
$_SESSION['customer_email']=$c_email;
echo "<script>alert('Accound has been created successfully')</script>";
echo "<script>window.open('checkout.php'.'_self')</script>";
}

?>

最佳答案

当您刷新已发布表单(method="POST")的页面时,您将重新发送数据。

关于javascript - 当我刷新页面时,数据自动存储在数据库中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38396841/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com