我正在网站上工作,我希望用户能够更新客户端的信息。我研究并尝试了很多次以使其工作,我编写代码就像在示例上一样,但是更新查询不适用于数据库,没有出现错误。 所以我希望找出在数据库中不会发生更新的原因。
以下是更新时的输出:
“记录更新成功”
这是update_prospect.php:
<?php
include 'connexion.php';
if(isset($_POST['telephone'])){$telephone= $_POST['telephone'];} else { $telephone='';}
if(isset($_POST['adresse'])){$adresse= $_POST['adresse'];} else { $adresse='';}
if(isset($_POST['ville'])){$ville= $_POST['ville'];} else { $ville='';}
if(isset($_POST['codepostal'])){$codepostal= $_POST['codepostal'];} else { $codepostal='';}
if(isset($_POST['mobile'])){$mobile= $_POST['mobile'];} else { $mobile='';}
if(isset($_POST['fax'])){$fax= $_POST['fax'];} else { $fax='';}
if(isset($_POST['email'])){$email= $_POST['email'];} else { $email='';}
if(isset($_POST['Typeprospect'])){$Typeprospect= $_POST['Typeprospect'];} else { $Typeprospect='';}
if(isset($_POST['observations'])){$observations= $_POST['observations'];} else { $observations='';}
if(isset($_POST['rcs'])){$rcs= $_POST['rcs'];} else { $rcs='';}
if(isset($_POST['numtva'])){$numtva= $_POST['numtva'];} else { $numtva='';}
if(isset($_POST['fonctionclient'])){$fonctionclient= $_POST['fonctionclient'];} else { $fonctionclient='';}
if(isset($_POST['raisonsociale'])){$raisonsociale= $_POST['raisonsociale'];} else { $raisonsociale='';}
if(isset($_POST['suffixedomaine'])){$suffixedomaine= $_POST['suffixedomaine'];} else { $suffixedomaine='';}
mysqli_begin_transaction($conn, MYSQLI_TRANS_START_READ_WRITE);
$sql ="UPDATE Client
SET
adresse='{$adresse}',
ville='{$ville}',
codepostal='{$codepostal}',
mobile='{$mobile}',
fax='{$fax}',
email='{$email}',
Typeprospect='{$Typeprospect}',
observations='{$observations}',
rcs='{$rcs}',
numtva='{$numtva}',
fonctionclient='{$fonctionclient}',
raisonsociale='{$raisonsociale}',
suffixedomaine='{$suffixedomaine}'
WHERE
telephone='{$telephone}'";
if (mysqli_query($conn,$sql) === TRUE)
{
echo "Record updated successfully";
}
else
{
echo "Error: " . $sql . "<br>" . $conn->error;
}
mysqli_commit($conn);
mysqli_close($conn);
?>