0
インストールされているWordpressでmysqlのデータを更新できるプラグインを作成しようとしていますが、私の管理リンクにフォームが表示されています。フォームへのアクセスは、フォームを一杯にしてEnregistrerにテーブルを何も変えないと、私はインターネット上にある多くのソリューションを試しましたが、機能しません。wordpressでmysqlを更新しない
function test_defaultval() {
echo '<form action="' . esc_url($_SERVER['REQUEST_URI']) . '"
method="post">';
echo '<p>';
echo 'perdiodecite (requis) <br />';
echo '<input type="text" name="cf-period" required pattern="[0-1]+"
size="40" />';
echo '</p>';
echo '<p>';
echo 'ville (requis) <br />';
echo '<input type="text" name="cf-ville" required size="40" />';
echo '</p>';
echo '<p>';
echo 'author (requis) <br />';
echo '<input type="text" name="cf-author" required pattern="[0-1]+"
size="40" />';
echo '</p>';
echo 'editor (requis) <br />';
echo '<input type="text" name="cf-editor" required pattern="[0-1]+"
size="40" />';
echo '</p>';
echo 'contrubutor (requis) <br />';
echo '<input type="text" name="cf-contrub" required pattern="[0-1]+"
size="40" />';
echo '</p>';
echo 'abonne (requis) <br />';
echo '<input type="text" name="cf-abonne" required pattern="[0-1]+"
size="40" />';
echo '</p>';
echo '<p><input type="submit" name="cf-submitted"
value="Enregistrer"/></p>';
echo '</form>';
}
function inserer_default() {
// if the submit button is clicked
if (isset($_POST['cf-submitted'])) {
// sanitize form values
$periodecite = sanitize_text_field($_POST["cf-period"]);
$ville = sanitize_text_field($_POST["cf-ville"]);
$Author = sanitize_text_field($_POST["cf-author"]);
$Editor = sanitize_text_field($_POST["cf-editor"]);
$Controbutor = sanitize_text_field($_POST["cf-contrub"]);
$Abonne = sanitize_text_field($_POST["cf-abonne"]);
// Code de traitement du formulaire : insertion dans la BD
global $wpdb;
$wpdb->query($wpdb->prepare("
UPDATE `wwpa_default` SET
defPeriodecite ='".$periodecite."'
defVille ='".$ville."'
defUserAuthor ='".$Author."'
defUserEditor ='".$Editor."'
defUserControbutor ='".$Controbutor."'
defUserAbonne ='".$Abonne."'
WHERE 1
"));
}
}
エラー報告を有効にしましたか? – Epodax
いいえ、私はどんなエラーも回しません。何も変えないでください。 – Bynd