我正在尝试插入两个不同的表,但最后一个表没有收到数据。没有显示错误我真的不知道这种情况可能是什么原因。是因为第二个表包含外键吗?
<?php
#connect to the db
require_once('db.inc.php');
?>
<?php
$date_created = date('y-m-d h:i:s a');
$username = (isset($_POST['username'])) ? trim($_POST['username']) : '';
$Previllage = (isset($_POST['Previllage'])) ? trim($_POST['Previllage']) : '';
#second tanble values
$title = (isset($_POST['title'])) ? trim($_POST['title']) : '';
$firstname = (isset($_POST['firstname'])) ? trim($_POST['firstname']) : '';
$lastname = (isset($_POST['lastname'])) ? trim($_POST['lastname']) : '';
$client_code = (isset($_POST['client_code'])) ? trim($_POST['client_code']) : '';
#end
$query = "INSERT INTO tish_user(username,Previllage,date_created)
VALUES(:username,:Previllage,:date_created)";
$insert = $con->prepare($query);
$insert->execute(array(':username' => $username,
':Previllage' => $Previllage,
'date_created' => $date_created));
# try another insert
$query = "INSERT INTO tish_clientinfor(title,firstname,lastname,client_code,date_registered)
VALUES(:title,:firstname,:lastname,:client_code,:date_registered)";
$insert = $con->prepare($query);
$insert->execute(array(
':title' => $title,
':firstname' => $firstname,
':lastname' => $lastname,
':client_code' => $client_code,
'date_registered' => $date_created));
?>