我正在使用以下脚本在我的网站上处理一个 php 表单,当我在表单上点击提交时,下面的脚本应该将数据保存到数据库中。我遇到的问题是它没有将任何数据保存到 mysql 数据库中,但它也没有抛出任何错误,为什么它也没有!?.
<link href='template/css/admin.css' rel='stylesheet' type='text/css'>
<?php
if (isset($_POST['customerID'])) {$customerID = $_POST['customerID'];}else {$customerID = '';}
if (isset($_POST['datecreated'])) {$datecreated = $_POST['datecreated'];}else {$datecreated = '';}
if (isset($_POST['name'])) {$name = $_POST['name'];}else {$name = '';}
if (isset($_POST['facebookuserurl'])) {$facebookuserurl = $_POST['facebookuserurl'];}else {$facebookuserurl = '';}
if (isset($_POST['tel'])) {$tel = $_POST['tel'];}else {$tel = '';}
if (isset($_POST['email'])) {$email = $_POST['email'];}else {$email = '';}
if (isset($_POST['address'])) {$address = $_POST['address'];}else {$address = '';}
if (isset($_POST['itemforrepair'])) {$itemforrepair = $_POST['itemforrepair'];}else {$itemforrepair = '';}
if (isset($_POST['repairdetails'])) {$repairdetails = $_POST['repairdetails'];}else {$repairdetails = '';}
if (isset($_POST['otherdetails'])) {$otherdetails = $_POST['otherdetails'];}else {$otherdetails = '';}
if (isset($_POST['itemnumber'])) {$itemnumber = $_POST['itemnumber'];}else {$itemnumber = '';}
if (isset($_POST['pricequoted'])) {$pricequoted = $_POST['pricequoted'];}else {$pricequoted = '';}
if (isset($_POST['partprice'])) {$partprice = $_POST['partprice'];}else {$partprice = '';}
$profit = $pricequoted - $partprice;
if (isset($_POST['datepartordered'])) {$datepartorderedpre = $_POST['datepartordered'];$date = DateTime::createFromFormat("D F d, Y", $datepartorderedpre);$datepartordered = date('Y-m-d',strtotime($datepartorderedpre));}else {$datepartorderedpre = ''; $datepartordered = '';}
if (isset($_POST['jobstatus'])) {$jobstatus = $_POST['jobstatus'];}else {$jobstatus = '';}
if (isset($_POST['dateofcompletion'])) {$dateofcompletionpre = $_POST['dateofcompletion'];$date = DateTime::createFromFormat("D F d, Y", $dateofcompletionpre);$dateofcompletion = date('Y-m-d',strtotime($dateofcompletionpre));}else {$dateofcompletionpre = ''; $dateofcompletion = '';}
// Checks to see if the key value is set
if (isset($_GET['key'])) {$key = $_GET['key'];} else {$key = '';}
// Checks to see if the key value is valid to authenticate the user
if ($key == 'mysecretkey'){
// If the key value is correct the user is granted access
include("connectmysqli.php");
$stmt = $db->prepare("UPDATE `jobdetails` SET itemnumber='$itemnumber',datecreated='$datecreated',customerID='$customerID',name='$name',facebookuserurl='$facebookuserurl',tel='$tel',email='$email',address='$address',itemforrepair='$itemforrepair',repairdetails='$repairdetails',otherdetails='$otherdetails',pricequoted='$pricequoted',partprice='$partprice',profit='$profit',datepartordered='$datepartordered',jobstatus='$jobstatus',dateofcompletion='$dateofcompletion' WHERE customerID='$customerID'");
$stmt->execute();
if (!$stmt)
echo $db->error . "\n";
$stmt->close();
header('Location: jobsmanager.php?&key='.$key);
}
else {
// Denies the user access if the key value isnt correct
echo '<h1>Access Denied !</h1>';}
?>