1

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

<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>
  <div class="form-group">
    <label>Durée</label>
    <input type="number" class="form-control" id="dureeA">
    <small id="dureeHelp" class="form-text text-muted">En jours</small>
  </div>
  <div class="form-group">
    <label>Nombre de produit autorisé</label>
    <input type="number" class="form-control" id="nbProdA">
  </div>
  <div class="form-group">
    <label>Frais d'abonnement (€)</label>
    <input type="number" class="form-control" id="fraisA">
  </div>
  <button type="submit" name="create" class="btn btn-primary">Valider</button>
</form>

and this is the action of the creation :

create.php

<?php
  include'admin.php';
  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 ?

0

1 Answer 1

1

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"]

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.