我有一个简单的表单,它从ajax获取值并通过表单提交。现在我无法在表单提交后获得该值。
这是我的HTML表单
<form name="frm1" action="process_view_detail.php?cand_id=<?php echo $_SESSION["id"]
?>" method="post">
<?php
$q=$_GET["x"];
include('connection.php');
$sql ="select * from register where name like '%$q%' &&`r_bid`='".$_SESSION["id"]."'
";
$result = mysql_query($sql);
?>
<select name="rid" style="height: 30px;padding: 6px;width: 280px;">
<option value=""> Select Details </option>
<?php
while( $data = mysql_fetch_array($result))
{
echo'<option value='.$data["r_id"].'">'.$data["name"].'('.$data["reference"].
'</option>';
}
echo'</select>
<input type="button" value="Find Details" on Click=\'f1()\'>
</form>
这是我的JavaScript代码,用于检查用户是否选择了值。
function f1()
{
ok=0;
a=document.frm1.elements.rid.value;
b=a.length;
if(b=='')
{
alert("Please select Details to view info.");
ok=1;
}
if(ok==0)
{
document.frm1.submit();
}
}
这是我的process_view_detail.php
<?php
$cand_id=$_GET['cand_id'];
$id=$_POST['r_id'];
$sql = mysql_query("select * from register where `r_id`='$id' & r_bid='$cand_id'");
$res=mysql_num_rows($sql);
if($res!=0)
{
$count=1;
while($row=mysql_fetch_array($sql))
{
echo'<h2 class="title"><font size=5 color=#8B4513><u><center>Client Info</center>
</u</font></h2>';
echo '<table border=0 align="center" width=40% >
<tr><td><table width=100%>
<tr><td><font size=5 font color=brown><i>Name</td><td>'.$row['name'].'</td></tr>
<tr><td><font size=5 font color=brown><i>Reference</td
<td>'.$row['reference'].'</td</tr>
<tr><td><font size=5 font color=brown><i>Email</td><td>'.$row['email'].'</td></tr>
<tr><td><font size=5 font color=brown><i>Mobile No.</td><td>'.$row['mob_no'].'</td
</tr>
<tr><td><font size=5 font color=brown><i>Address</td><td>'.$row['addr'].'</td></tr>
<tr><td><font size=5 font color=brown><i>DOB</td><td>'.$row['dob'].'</td></tr>
<tr><td><font size=5 font color=brown><i>Age</td><td>'.$row['age'].'</td></tr>
<tr><td><font size=5 font color=brown><i>Blood Group</td><td>'.$row['blood_grp'].'</td>
</tr>
<tr><td><font size=5 font color=brown><i>Occupation</td><td>'.$row['occupation'].'</td>
</tr>
</font></table>
</td>
</tr>
</table>';
$count++;
}
}
?>
答案 0 :(得分:1)
如果操作位于其他页面,请尝试使用$someval = $_POST['rid'];
接收表单数据。
答案 1 :(得分:1)
而不是
$id=$_POST['r_id'];
应该是
$id=$_POST['rid'];