实时示例this is my sample live website
问题是当我离线使用它时,“ Contact-Us”的代码工作正常(wampserver),但是当我将其上传到cpanel时,它却无法正常工作……我尝试了几乎所有操作,但警报只是向我“连接失败”,Connection.php可以正常工作,我可以连接到数据库,问题似乎出在INSERT语句中。我在代码中看不到任何问题,因为我的其他“注册”表格可以在网上正常运行,请参见示例网站。我的代码没有错误问题,因为我已经检查了错误日志:
<?php
include_once 'Connection.php';
if(isset($_POST['btn-index']))
{
$first_name = $_POST['first_name'];
$email = $_POST['email'];
$contact = $_POST['contact'];
$subject = $_POST['subject'];
$message = $_POST['workarea'];
$first_name = stripslashes($_REQUEST['first_name']);
$first_name = mysqli_real_escape_string($conn,$first_name);
$email = stripslashes($_REQUEST['email']);
$email = mysqli_real_escape_string($conn,$email);
$contact = stripslashes($_REQUEST['contact']);
$contact = mysqli_real_escape_string($conn,$contact);
$subject = stripslashes($_REQUEST['subject']);
$subject = mysqli_real_escape_string($conn,$subject);
$message = stripslashes($_REQUEST['workarea']);
$message = mysqli_real_escape_string($conn,$message);
$sql = "INSERT INTO `inquiry` (First_Name,Email,Contact,Subj,Message)
VALUES('$first_name','$email','$contact','$subject','$message')";
if($conn->query($sql) === TRUE)
{
?>
<script>
alert('Records Submitted!');
window.location.href='index.php#parent_contacts';
</script>
<?php
}
else
{
?>
<script>
alert('Connection Failed...');
window.location.href='index.php#parent_contacts';
</script>
<?php
}
$conn->close();
}
//---------FOR ABOUT-US.PHP-------------------------
if(isset($_POST['btn-contact']))
{
$name = $_POST['name'];
$email = $_POST['email'];
$contact = $_POST['contact'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$name = stripslashes($_REQUEST['name']);
$name = mysqli_real_escape_string($conn,$name);
$email = stripslashes($_REQUEST['email']);
$email = mysqli_real_escape_string($conn,$email);
$contact = stripslashes($_REQUEST['contact']);
$contact = mysqli_real_escape_string($conn,$contact);
$subject = stripslashes($_REQUEST['subject']);
$subject = mysqli_real_escape_string($conn,$subject);
$message = stripslashes($_REQUEST['message']);
$message = mysqli_real_escape_string($conn,$message);
$sql = "INSERT INTO `inquiry` (First_Name,Email,Contact,Subj,Message)
VALUES('$name','$email','$contact','$subject','$message')";
if($conn->query($sql) === TRUE)
{
?>
<script>
alert('Records Submitted!');
window.location.href='Contact-Us.php';
</script>
<?php
}
else
{
?>
<script>
alert('Connection Failed...');
window.location.href='Contact-Us.php';
</script>
<?php
}
$conn->close();
}
?>
答案 0 :(得分:0)
重新编写代码后,我终于解决了问题。原来问题出在我的SQL表上..行没有排序规则,所有行都变成“ int”,不知道是什么导致了Godaddy myphpAdmin上的触发,但是使用本地时,在我的沼泽上工作得很好