title: Submitting a php pop-up form with javascript
body: <p>I have a pop up form in php that is opened by javascript. I want this to be sent to my database when I click on submit. The php form works fine without the javascript, but when added it doesn t work. Would you have any idea how to solve this.</p>
  
  <pre><code> &lt;/style&gt;
   &lt;script type='text/javascript'&gt;
   $(document).ready(function() {
    $('#box_form').dialog({
      autoOpen: false,
      height: 375,
      width: 350,
      modal: true,
      buttons: [
          {
          text: "Cancel",
          click: function() {
              $(this).dialog("close");
          }},
      {
          text: "Submit",
          click: function() {
              $('#former').submit();
          }}
      ]
  });
  $('#clicky').button().click(function(e){
      $('#box_form').dialog('open');
  });
    });
      &lt;/script&gt;
      &lt;/head&gt;
     &lt;body&gt;
     &lt;form id="former" method="post" action="film_post.php" name="former"&gt;
    &lt;div id="box_form"&gt;
     &lt;select id="option" name="option"&gt;
                      &lt;option value="film"&gt;film&lt;/option&gt;
                      &lt;option value="livre"&gt;livre&lt;/option&gt;
                      &lt;option value="musique"&gt;musique&lt;/option&gt;            
              &lt;/select&gt;&lt;/p&gt;
      &lt;p&gt;
      &lt;select id="star" name="star"&gt;
                      &lt;option value="1"&gt;1&lt;/option&gt;
                      &lt;option value="2"&gt;2&lt;/option&gt;
                      &lt;option value="3"&gt;3&lt;/option&gt; 
  
              &lt;/select&gt;&lt;/p&gt;
      &lt;label for="nom"&gt;nom&lt;/label&gt; :  &lt;input type="text" name="nom" id="nom" /&gt;&lt;br /&gt;
  
   &lt;/div&gt;
   &lt;/form&gt;
   &lt;input type="button" id="clicky" value="Show Form"&gt;
  </code></pre>
  
  <p>and the film_post.php file is: </p>
  
  <pre><code>  try
    {
  $bdd = new PDO('mysql:host=localhost;dbname=website', 'root', 'root');
     }
    catch(Exception $e)
   {
      die('Erreur : '.$e-&gt;getMessage());
     }
  
      $option = $_POST['option'];
        $star = $_POST['star'];
  
      if ($option == film AND $star = 1) {
     $req = $bdd-&gt;prepare('INSERT INTO film (film, star) VALUES(?,?)');
       $req-&gt;execute(array($_POST['nom'],$_POST['star'] )); }
  
       elseif ($option == film AND $star = 2) {
      $req = $bdd-&gt;prepare('INSERT INTO film (film, star) VALUES(?,?)');
      $req-&gt;execute(array($_POST['nom'],$_POST['star'] )); }
  
       elseif ($option == film AND $star = 3) {
     req = $bdd-&gt;prepare('INSERT INTO film (film, star) VALUES(?,?)');
     $req-&gt;execute(array($_POST['nom'],$_POST['star'] )); }
  </code></pre>