我的数据没有插入数据库
我的数据有问题,即使我的代码中没有出现错误,它们也没有插入数据库 这是插入代码
<?php
$objPdo = new PDO('mysql:host=localhost;dbname=bea','root','');
if(isset($_POST['suiv']) && isset($_FILES['actenaisss']) && isset($_FILES['piec']) && isset($_FILES['resid'])){
include "config.php";
echo "<pre>";
print_r($_FILES['actenaisss']);
print_r($_FILES['piec']);
print_r($_FILES['resid']);
echo "</pre>";
$img_name = $_FILES['actenaisss']['name'];
$img_size = $_FILES['actenaisss']['size'];
$tmp_name = $_FILES['actenaisss']['tmp_name'];
$error = $_FILES['actenaisss']['error'];
$img_name1 = $_FILES['piec']['name'];
$img_size1 = $_FILES['piec']['size'];
$tmp_name1 = $_FILES['piec']['tmp_name'];
$error1 = $_FILES['piec']['error'];
$img_name2 = $_FILES['resid']['name'];
$img_size2 = $_FILES['resid']['size'];
$tmp_name2 = $_FILES['resid']['tmp_name'];
$error2 = $_FILES['resid']['error'];
/* $numps = $_POST['numps'];
$numan = $_POST['numan'];
$typep = $_POST['typep'];*/
if ($error === 0 && $error1 === 0 && $error2 === 0) {
if ($img_size > 125000 && $img_size1 > 125000 && $img_size2 >125000) {
$em = "Sorry, your file is too large !";
header("Location: form-merci.php?error=$em");
}else{
$img_ex = pathinfo($img_name, PATHINFO_EXTENSION);
$img_ex1 = pathinfo($img_name1, PATHINFO_EXTENSION);
$img_ex2 = pathinfo($img_name2, PATHINFO_EXTENSION);
$img_ex_lc = strtolower($img_ex);
$img_ex_lc1 = strtolower($img_ex1);
$img_ex_lc2 = strtolower($img_ex2);
$allowed_exs = array("jpg", "jpeg", "png", "JPG", "JPEG", "PNG", "PDF", "pdf", "txt", "TXT");
if (in_array($img_ex_lc, $allowed_exs) && in_array($img_ex_lc1, $allowed_exs) && in_array($img_ex_lc2, $allowed_exs)) {
$new_img_name = uniqid("IMG-", true).'.'.$img_ex_lc;
$new_img_name1 = uniqid("IMG-", true).'.'.$img_ex_lc1;
$new_img_name2 = uniqid("IMG-", true).'.'.$img_ex_lc2;
$img_upload_path = 'files/'.$new_img_name;
$img_upload_path1 = 'files/'.$new_img_name1;
$img_upload_path2 = 'files/'.$new_img_name2;
move_uploaded_file($tmp_name, $img_upload_path);
move_uploaded_file($tmp_name1, $img_upload_path1);
move_uploaded_file($tmp_name2, $img_upload_path2);
$pdoStat = $objPdo->prepare('INSERT INTO formulaire_depot VALUES(NULL, :nom, :prenom, :nais, :lnais, :pprenom, :mnom, :mprenom, :actenais, :typepie, :numpi, :datedeliv, :delivpar, :prof, :numero, :email, :actenaisss, :piec, :resid)');
$pdoStat->bindValue(':nom', $_POST['nom'], PDO::PARAM_STR);
$pdoStat->bindValue(':prenom', $_POST['prenom'], PDO::PARAM_STR);
$pdoStat->bindValue(':nais', $_POST['nais'], PDO::PARAM_STR);
$pdoStat->bindValue(':lnais', $_POST['lnais'], PDO::PARAM_STR);
$pdoStat->bindValue(':pprenom', $_POST['pprenom'], PDO::PARAM_STR);
$pdoStat->bindValue(':mnom', $_POST['mnom'], PDO::PARAM_STR);
$pdoStat->bindValue(':mprenom', $_POST['mprenom'], PDO::PARAM_STR);
$pdoStat->bindValue(':actenais', $_POST['actenais'], PDO::PARAM_STR);
$pdoStat->bindValue(':typepie', $_POST['typepie'], PDO::PARAM_STR);
$pdoStat->bindValue(':numpi', $_POST['numpi'], PDO::PARAM_STR);
$pdoStat->bindValue(':datedeliv', $_POST['datedeliv'], PDO::PARAM_STR);
$pdoStat->bindValue(':delivpar', $_POST['delivpar'], PDO::PARAM_STR);
$pdoStat->bindValue(':prof', $_POST['prof'], PDO::PARAM_STR);
$pdoStat->bindValue(':numero', $_POST['numero'], PDO::PARAM_STR);
$pdoStat->bindValue(':email', $_POST['email'], PDO::PARAM_STR);
$pdoStat->bindValue(':actenaisss', $new_img_name, PDO::PARAM_STR);
$pdoStat->bindValue(':piec', $new_img_name1, PDO::PARAM_STR);
$pdoStat->bindValue(':resid', $new_img_name2, PDO::PARAM_STR);
$insert = $pdoStat->execute();
if ($insert) {
header("Location: form-merci.php");
}
}else{
$em = "You can't upload this type of file!";
header("Location: form-merci.php?error=$em");
}
}
}else{
$em = "unknown error occurred!";
header("Location: form-merci.php?error=$em");
}
}else{
header("Location: form-merci.php");
}
?>
在添加文件输入之前完美工作的插入代码,当我单击“提交”按钮时添加文件时,它将我带到“ form-merci.php”,这意味着数据正在插入成功,但是当我去phpmyadmin中的桌子,我找不到数据插入 请帮助我,我真的需要它,谢谢!
I have a problem with my data they're not inserting into the database even though There is no error showed in my code
here is the insertion code
<?php
$objPdo = new PDO('mysql:host=localhost;dbname=bea','root','');
if(isset($_POST['suiv']) && isset($_FILES['actenaisss']) && isset($_FILES['piec']) && isset($_FILES['resid'])){
include "config.php";
echo "<pre>";
print_r($_FILES['actenaisss']);
print_r($_FILES['piec']);
print_r($_FILES['resid']);
echo "</pre>";
$img_name = $_FILES['actenaisss']['name'];
$img_size = $_FILES['actenaisss']['size'];
$tmp_name = $_FILES['actenaisss']['tmp_name'];
$error = $_FILES['actenaisss']['error'];
$img_name1 = $_FILES['piec']['name'];
$img_size1 = $_FILES['piec']['size'];
$tmp_name1 = $_FILES['piec']['tmp_name'];
$error1 = $_FILES['piec']['error'];
$img_name2 = $_FILES['resid']['name'];
$img_size2 = $_FILES['resid']['size'];
$tmp_name2 = $_FILES['resid']['tmp_name'];
$error2 = $_FILES['resid']['error'];
/* $numps = $_POST['numps'];
$numan = $_POST['numan'];
$typep = $_POST['typep'];*/
if ($error === 0 && $error1 === 0 && $error2 === 0) {
if ($img_size > 125000 && $img_size1 > 125000 && $img_size2 >125000) {
$em = "Sorry, your file is too large !";
header("Location: form-merci.php?error=$em");
}else{
$img_ex = pathinfo($img_name, PATHINFO_EXTENSION);
$img_ex1 = pathinfo($img_name1, PATHINFO_EXTENSION);
$img_ex2 = pathinfo($img_name2, PATHINFO_EXTENSION);
$img_ex_lc = strtolower($img_ex);
$img_ex_lc1 = strtolower($img_ex1);
$img_ex_lc2 = strtolower($img_ex2);
$allowed_exs = array("jpg", "jpeg", "png", "JPG", "JPEG", "PNG", "PDF", "pdf", "txt", "TXT");
if (in_array($img_ex_lc, $allowed_exs) && in_array($img_ex_lc1, $allowed_exs) && in_array($img_ex_lc2, $allowed_exs)) {
$new_img_name = uniqid("IMG-", true).'.'.$img_ex_lc;
$new_img_name1 = uniqid("IMG-", true).'.'.$img_ex_lc1;
$new_img_name2 = uniqid("IMG-", true).'.'.$img_ex_lc2;
$img_upload_path = 'files/'.$new_img_name;
$img_upload_path1 = 'files/'.$new_img_name1;
$img_upload_path2 = 'files/'.$new_img_name2;
move_uploaded_file($tmp_name, $img_upload_path);
move_uploaded_file($tmp_name1, $img_upload_path1);
move_uploaded_file($tmp_name2, $img_upload_path2);
$pdoStat = $objPdo->prepare('INSERT INTO formulaire_depot VALUES(NULL, :nom, :prenom, :nais, :lnais, :pprenom, :mnom, :mprenom, :actenais, :typepie, :numpi, :datedeliv, :delivpar, :prof, :numero, :email, :actenaisss, :piec, :resid)');
$pdoStat->bindValue(':nom', $_POST['nom'], PDO::PARAM_STR);
$pdoStat->bindValue(':prenom', $_POST['prenom'], PDO::PARAM_STR);
$pdoStat->bindValue(':nais', $_POST['nais'], PDO::PARAM_STR);
$pdoStat->bindValue(':lnais', $_POST['lnais'], PDO::PARAM_STR);
$pdoStat->bindValue(':pprenom', $_POST['pprenom'], PDO::PARAM_STR);
$pdoStat->bindValue(':mnom', $_POST['mnom'], PDO::PARAM_STR);
$pdoStat->bindValue(':mprenom', $_POST['mprenom'], PDO::PARAM_STR);
$pdoStat->bindValue(':actenais', $_POST['actenais'], PDO::PARAM_STR);
$pdoStat->bindValue(':typepie', $_POST['typepie'], PDO::PARAM_STR);
$pdoStat->bindValue(':numpi', $_POST['numpi'], PDO::PARAM_STR);
$pdoStat->bindValue(':datedeliv', $_POST['datedeliv'], PDO::PARAM_STR);
$pdoStat->bindValue(':delivpar', $_POST['delivpar'], PDO::PARAM_STR);
$pdoStat->bindValue(':prof', $_POST['prof'], PDO::PARAM_STR);
$pdoStat->bindValue(':numero', $_POST['numero'], PDO::PARAM_STR);
$pdoStat->bindValue(':email', $_POST['email'], PDO::PARAM_STR);
$pdoStat->bindValue(':actenaisss', $new_img_name, PDO::PARAM_STR);
$pdoStat->bindValue(':piec', $new_img_name1, PDO::PARAM_STR);
$pdoStat->bindValue(':resid', $new_img_name2, PDO::PARAM_STR);
$insert = $pdoStat->execute();
if ($insert) {
header("Location: form-merci.php");
}
}else{
$em = "You can't upload this type of file!";
header("Location: form-merci.php?error=$em");
}
}
}else{
$em = "unknown error occurred!";
header("Location: form-merci.php?error=$em");
}
}else{
header("Location: form-merci.php");
}
?>
It was working perfectly before adding the files inputs and when I added the files when I click on the submit button it takes me to the "form-merci.php" which means that the data are inserting successfuly but when I go the the table in phpmyadmin I don't find the data insert
Please help me with this I really need it Thank you !!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论