1
<a class="btn btn-primary" id="popover">xxx</a></li> 
                  <div id="popover-head" class="hide"><h3 class="popover-title" style="color:#333;">xxx</h3></div> 
                  <div id="popover-content" class="hide"> 
<?php 
      // check for a successful form post 
      if (isset($_GET['s'])) echo "<div class=\"alert alert-success\">".$_GET['s']."</div>"; 
      // check for a form error 
      elseif (isset($_GET['e'])) echo "<div class=\"alert alert-danger\">".$_GET['e']."</div>"; 
     ?> 
     <form role="form" method="POST" action="*.php"> 
       <div class="row"> 
       <div class="form-group col-lg-12"> 
        <label for="input1">Name</label> 
        <input type="text" name="contact_name" class="form-control" id="input1"> 
       </div> 
       </div> 
       <div class="row"> 
       <div class="form-group col-lg-12"> 
        <label for="input2">Email Address</label> 
        <input type="email" name="contact_email" class="form-control" id="input2"> 
       </div> 
       </div> 
       <div class="row"> 
       <div class="form-group col-lg-12"> 
        <label for="input3">Phone Number</label> 
        <input type="phone" name="contact_phone" class="form-control" id="input3"> 
       </div> 
       </div> 
       <div class="clearfix"></div> 
       <div class="form-group col-lg-12"> 
        <label for="input4">We will be in touch soon!</label> 
        <textarea name="contact_message" rows="6" style="display:none" class="form-control" id="input4">xxx</textarea> 
       </div> 
       <div class="form-group col-lg-12"> 
       <input type="hidden" name="save" value="contact"> 
       <button type="submit" class="btn btn-primary">Submit</button> 
       </div> 
      </div> 
     </form> 

我有2個問題,用這段代碼。第一個問題是,當我將表單插入到bootstrap3彈出窗口時,它會中斷。第二個問題是popover不會打開。如果我從中刪除代碼,popover會打開,如果不在popover中,php腳本將運行。Bootstrap3,Popover,PHP - 聯繫表單內部破碎,Popover中斷內容

回答

0

一個甚至不需要popover.This的簡單代碼也打破Bootstrap 3!

<form class="navbar-form navbar-left" name="contact" action="<?php echo $_SERVER('PHP_SELF'); ?>" method="get"> 
    <div class="form-group"> 
     <p> 
     <label for="name">Name</label> 
     <input type="text" name="name" id="name"> 
     </p> 
     <p> 
     <label for="email">Email</label> 
     <input type="text" name="email" id="email"> 
     </p> 
     <p> 
     <label for="comments">Comments</label> 
     <textarea name="comments" id="comments"></textarea> 
     </p> 
    </div> 
    <p> 
     <input type="submit" name="send" id="send" value="Send Comments"> 
    </p> 
    </form> 
    <?php 
if($_GET){ 
     echo "Contents of the $_GET array<br >"; 
     print_r($_GET); 
    }elseif ($_POST){ 
         echo "Contents of the $_POST array<br >"; 
     print_r($_POST); 
     } 

?>