0

我有 php 表单提交代码将数据输入 phpmyadmin。当我尝试执行我的代码时,我看到我的数据被插入到我的表中。但是当我重新加载浏览器时(我使用的是 chrome 和 mozilla,并且我清除了 chrome 和 mozilla 的 coockies),我的表中的数据丢失了。

我的问题是什么导致我的表中的数据丢失?我的代码有问题还是服务器有问题?

注意:我在网上工作,而不是在我的本地服务器(XAMPP)上

这是我的代码:

// Insert
if ($menu=='news' AND $submit=='input'){
$file_loc    = $_FILES['upload']['tmp_name']
$file_type   = $_FILES['upload']['type'];
$file_name   = $_FILES['upload']['name'];
$rand        = rand(1,99);
$unique_file = $rand.$file_name;


// If any image uploaded
if (!empty($file_loc)){
if ($file_type != "image/jpeg" AND $file_type != "image/pjpeg"){
echo "<script>alert('Upload failed. Be sure your image is JPEG
format.');window.history.go(-1);</script>"; 
} else {
mysql_query("INSERT INTO news (title, category_name, news_content, date, time, image) VALUES ('$_POST['title']', '$_POST['category_name']','$_POST['news_content']', '$date', '$time', '$_POST['tag']', '$unique_file')");
    header('location:../../media.php?menu='.$menu);
    }
  }
}

感谢您的任何建议和指导

4

0 回答 0