내 웹 사이트에서 이상한 행동을하고 있습니다. 사실 내 dB에 채워진 데이터를 삽입하는 기본 PHP 스크립트가있는 간단한 양식입니다.
내 컴퓨터에서 문제를 재현하지 못했지만 클라이언트 컴퓨터에서 원격 연결을 통해이를 관찰했습니다.
이상한 점은 때로는 내 스크립트에 $ _POST가 완전히 비어 있다는 것입니다. 양식이 잘 채워질 때가 있습니다. 그리고 나머지는 실제로 제대로 작동합니다.
문제가 발생하기 전에 제출할 때 대기 시간이 길어졌습니다. 여기
은 (당신이 볼로는 WP이야) 일부 코드 :형태 :
<form id="filmform" action="<?php bloginfo('url'); ?>/post-film" method="post" enctype="multipart/form-data">
<fieldset>
<p>
<label for="titre_film">Titre du film *</label>
<input type="text" name="titre_film" id="titre_film" value="<?php echo (isset($_SESSION["form"]["titre_film"])) ? $_SESSION["form"]["titre_film"] : "" ?>" style="width:300px"/>
</p>
<p>
<label for="affiche">Affiche du film</label>
<input type="file" name="affiche" id="affiche" />
</p>
<p>
<label for="nom_realisateur">Nom du/des réalisateur(s) *</label>
<input type="text" name="nom_realisateur" id="nom_realisateur" value="<?php echo (isset($_SESSION["form"]["nom_realisateur"])) ? $_SESSION["form"]["nom_realisateur"] : "" ?>" style="width:200px" />
</p>
<p>
<label for="nationalite_realisateur">Nationalité du/des réalisateur(s) *</label>
<input type="text" name="nationalite_realisateur" id="nationalite_realisateur" value="<?php echo (isset($_SESSION["form"]["nationalite_realisateur"])) ? $_SESSION["form"]["nationalite_realisateur"] : "" ?>" style="width:200px" />
</p>
<p>
<label for="societe_production">Société de production *</label>
<input type="text" name="societe_production" id="societe_production" value="<?php echo (isset($_SESSION["form"]["societe_production"])) ? $_SESSION["form"]["societe_production"] : "" ?>" style="width:200px" />
</p>[...]
<input type="hidden" name="action" value="wp_handle_upload" />
<p><input type="submit" name="wp-submit" value="Inscription" /> - <input type="button" value="Imprimer" onclick="window.print()" style="cursor:pointer" /> - <input type="reset" value="Remettre le formulaire à 0" style="cursor:pointer" /></p>
</fieldset>
</form>
내 스크립트를
<?php
/*
Template Name: Récupération données formulaire film
*/
$array_field_required = array(
"categories_inscription",
"titre_film",
"reglement",
"reglement2",
"nom_realisateur",
"email_societe_production",
"societe_production_luxembourgeoise",
"nationalite_realisateur",
"producteur_delegue",
"distribution"
);
$no_meta_for_those_fields = array(
"categories_inscription",
"titre_film",
"reglement",
"reglement2",
"action",
"wp-submit",
"email_societe_production",
"redirect_to"
);
$array_errors = array();
$message_admin = "";
foreach($_POST as $key => $value) {
$_SESSION["form"][$key] = $value;
}
foreach($array_field_required as $required_field) {
if (!isset($_POST[$required_field]) || empty($_POST[$required_field])) {
$array_errors[] = $required_field;
}
}
if (sizeof($array_errors) > 0) {
wp_redirect(get_bloginfo('url') . "/inscrire-un-film?errors=" . implode(";", $array_errors));
exit();
}
$post = array(
"post_type" => "film",
"post_category" => $_POST["categories_inscription"],
"post_name" => $_POST["titre_film"],
"post_title" => $_POST["titre_film"]
);
$post_id = wp_insert_post($post, false);
if($post_id) {
$unique = true;
foreach($_POST as $key => $value) {
if (!in_array($key, $no_meta_for_those_fields)) {
add_post_meta($post_id, $key, $value, $unique);
}
}
add_post_meta($post_id, 'actif', 0, true);
if (! function_exists('wp_handle_upload')) require_once(ABSPATH . 'wp-admin/includes/file.php');
$uploadedfile = $_FILES['affiche'];
$upload_overrides = array('test_form' => false);
$movefile = wp_handle_upload($uploadedfile, $upload_overrides);
$attachment = array(
'post_mime_type' => $movefile["type"],
'guid' => $movefile["url"],
'post_parent' => $post_id,
'post_title' => $_FILES['affiche']["name"],
'post_content' => "",
);
$attach_id = wp_insert_attachment($attachment, $movefile, $post_id);
if ($attach_id) {
set_post_thumbnail($post_id, $attach_id);
}
wp_redirect(get_bloginfo('url')."/droits-d-inscription");
} else {
wp_redirect(get_bloginfo('url')."/inscrire-un-film");
}
exit();
당신이 어떤 생각을 가지고 있습니까 저를 도울 수 있습니까?
덕분에, 줄리앙
코드 또는 예제가 있습니까? ... – Patrick
음 ... 코드를 보는 것이 도움이 될 것입니다. P –
세부 정보 필요 : 몇 개의 입력란을 제출 하시겠습니까? 파일을 업로드하고 있습니까? 클라이언트가 사용하는 브라우저/바이러스 백신/방화벽은 무엇입니까? – neelsg