PHP将表单提交到另一个页面,然后运行该方法

时间:2017-03-08 23:19:39

标签: php submit

我有2个php文件:a.php和b.php

我想将数据从a.php提交到b.php。但我尝试过,而不是在b.php中运行。 (我想在a.php中输入之后在b.php中运行“搜索”方法。)

由于

这是我的代码

a.php

library(dplyr)
Test %>% 
  group_by(Individual) %>%
  filter(all(c("Test1", "Test2", "Test3") %in% ExamNumber)) %>%
  ungroup()

# A tibble: 6 × 2
  Individual ExamNumber
      <fctr>     <fctr>
1      Alice      Test1
2      Alice      Test2
3      Alice      Test3
4        Eve      Test1
5        Eve      Test2
6        Eve      Test3

b.php

<form action="b.php" name="form1" method="post" >
<input type="search" name="search" id="search" >
<input type="submit" value=" "></form> 

1 个答案:

答案 0 :(得分:0)

尝试使用以下代码

a.php只会

<form action="b.php" name="form1" method="post" >
   <input type="search" name="search" id="search" >
   <input type="submit" name="cari" value="submit">
</form> 

b.php

<form id="form1" name="form1" method="post" action="" >
    <input type="search" value="<?php echo $_POST['search'];?>" name="search">
    <input type="submit" name="cari" value="submit">
</form> 
<table>

<?php $search = $_POST['search'];
    if(($search != "") && ($_POST['cari'] != "")) { 
        $query = "SELECT * FROM kondef WHERE poin like '%$search%' or deskripsi like '%$search%'";
        $result = $db->query($query);
    } else {
        die (mysql_error()); 
    };
    while($row = $result->fetchArray()) {?>
    <tr>
        <td><?php echo $row['poin'];?></td>
        <td><?php echo $row['deskripsi'];?></td>
        <td><?php echo $row['link'];?></td>
    </tr>
    <?php } ?>
</table>