【发布时间】:2014-11-13 18:09:51
【问题描述】:
我的问题接近于此: PHP: 2 forms different action pages, only 1 form action works
我正在制作一个 php 页面,该页面从 form1 获取学生姓名的搜索值 并列出匹配的学生姓名,并在每个学生下方有一个按钮删除学生(form2) 现在表单 2 action=delete.php 不起作用。
<?php $results = array();
$results = mysql_fetch_array($raw_results);
echo ''.$ln.' matches found as following:';
for($i=0;$i<$ln;$i++){ ?>
<ul data-role="listview" data-divider-theme="d" data-inset="false">
<li data-role="list-divider" role="heading">
<?php echo 'StudentName:'; echo (" $results[3] "); ?>
</li>
<li data-theme="c">
<?php echo 'Email:'; echo (" $results[4] "); ?>
</li></ul>
<?php echo' <form name="form1" method="post" action="delete.php"> /*here is the problem*/
<input type="button" name="delete" class="button red" value="Delete member">
<input type="hidden" name="id" value="'. $results[0].'" >
</form> '; ?>
你可能会问为什么我用 echo 打印表单?因为我也试过了,但没有成功:
<form name="form1" method="post" action="delete.php">
<input type="button" name="delete" class="button red" value="Delete member">
<input type="hidden" name="id" value="<?php echo $results['0']; ?>" >
</form>
这是删除student.php
<?php
include ('connect.php');
if (isset($_POST['delete'])) {
$mid=$_POST['id'];
mysql_query(" DELETE FROM member WHERE (m_id='$mid') ");
}
?>
希望理由清楚,如果需要,我准备写更多细节
【问题讨论】:
标签: php html forms post action