2017-10-22 12:49
浏览 119

使用php WordPress提交表单

Hello I work with WordPress , and I create a custom Modal with form to add a Group called 'abonnement' I added the table in Database and this is my issue:


<form name="abonnementCreate" action="create.php" method="POST">
  <div class="form-group">
    <label>Nom de l'abonnemnt</label>
    <input type="text" class="form-control" id="nomA" name="nomA">
  <div class="form-group">
    <input type="number" class="form-control" id="dureeA">
    <small id="dureeHelp" class="form-text text-muted">En jours</small>
  <div class="form-group">
    <label>Nombre de produit autorisé</label>
    <input type="number" class="form-control" id="nbProdA">
  <div class="form-group">
    <label>Frais d'abonnement (€)</label>
    <input type="number" class="form-control" id="fraisA">
  <button type="submit" name="create" class="btn btn-primary">Valider</button>

and this is the action of the creation :


  global $wpdb;

  if(isset( $_POST["create"]))
     $wpdb->insert('abonnement', array(
     'nom' => '.$_POST["nomA"].',
     'duree' => '.$_POST["dureeA"].',
     'nbProd' => '.$_POST["nbProdA"].',
     'frais' => '.$_POST["fraisA"].' 

I have $_POST["create"] and the condition is true but $_POST[" any field"] is always null,
Someone please can help me ?

图片转代码服务由CSDN问答提供 功能建议

您好我使用WordPress,我创建了一个带有表单的自定义模态,以添加一个名为'abonnement'的组我添加了 这是我的问题:


 &lt; form name =“abonnementCreate  “action =”create.php“method =”POST“&gt; 
&lt; div class =”form-group“&gt; 
&lt; label&gt; Nom de l'abonnemnt&lt; / label&gt; 
&lt;输入类型 =“text”class =“form-control”id =“nomA”name =“nomA”&gt; 
&lt; / div&gt; 
&lt; div class =“form-group”&gt; 
&lt; label&gt;  Durée&lt; / label&gt; 
&lt; input type =“number”class =“form-control”id =“dureeA”&gt; 
&lt; small id =“dureeHelp”class =“form-text text-muted”&gt  ; En jours&lt; / small&gt; 
&lt; / div&gt; 
&lt; div class =“form-group”&gt; 
&lt; label&gt; Nombre deproduitautorisé&lt; / label&gt; 
&lt; input type =“  number“class =”form-control“id =”nbProdA“&gt; 
&lt; / div&gt; 
&lt; div class =”form-group“&gt; 
&lt; label&gt; Frais d'abonnement(€)  &LT; /  label&gt; 
&lt; input type =“number”class =“form-control”id =“fraisA”&gt; 
&lt; / div&gt; 
&lt; button type =“submit”name =“create”class =  “btn btn-primary”&gt; Valider&lt; / button&gt; 
&lt; / form&gt; 

这是创作的动作: \ n


 global $ wpdb; \  n 
 if(isset($ _POST [“create”]))
 $ wpdb-&gt; insert('abonnement',array(
'nom'=&gt;  '。$ _ POST [“nomA”]。',
'duree'=&gt;  '。$ _ POST [“dureeA”]。',
'nbProd'=&gt;  '。$ _ POST [“nbProdA”]。',
'frais'=&gt;  '$ _ POST [ “fraisA”。'  

我有$ _POST [“create”]且条件为true但$ _POST [“任何 字段“]总是空的,

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doushi3322 2017-10-22 13:37

    you can never catch the post value from id of the form input field.only way that you can get value using $_POST[] is using the "name" attribute of the input field.

        <input type="text" class="form-control" id="nomA" name="name1">

    this input field value can be accessed from form action php file using $_POST["name1"]

    解决 无用
    打赏 举报

相关推荐 更多相似问题