2017-02-10 48 views
-1

我有这种形式喂入我的网站上显示的表格。自动重新加载/刷新用户输入的PHP

当前,当用户输入并提交数据时,用户需要刷新页面以显示新的数据。

每当用户按下ENTER键或从表单提交数据时,表格是否可以自动刷新?

<table> 
    <tr> 
    <th><div class="search-box"> 
     <iframe name="votar" style="display:none;"></iframe> 
     <form action="protected_page.php" method="post" target="votar"> 
     <input type="text" autocomplete="off" placeholder="Busca tu producto" name="producto" size="60" /> 

     <div class="result"></div> 
     <input type="hidden" name="usuario" value="<?php echo htmlentities($_SESSION['username']); ?>" /></th> 
    <th><input type="submit" name="mandar"/> 
    <th><input type='submit' name='reload' value='UPDATE' />  
       </form> 
</th> 

    </tr> 
</table> 
    <?php 
    if(isset($_POST['mandar'])){ 

     $sql_man="INSERT INTO busca (producto, username) VALUES ('$_POST[producto]','$_POST[usuario]')"; 

     $mysqli->query($sql_man); 

     header("Location: /protected_page.php"); 

     } 
     if(isset($_POST['reload'])){   
     header("Location: /protected_page.php"); 
     } 
    ?> 
    </div> 
+0

你可以使用多个表单提交... – Gulshan

+0

你究竟想要什么?这样一个模棱两可的问题。 – WeAreRight

+0

我编辑了这个问题,使其更加清晰。 – Rocko

回答

0

您可以使用JavaScript来重新加载页面。

echo"<script>window.location.reload();</script>"; 
0

echo“window.location.reload(true);”;