我知道当单击提交按钮时可以在 url 中传递一个值,例如:
action= assignastemp.php?value1=a
然后在 assignastemp 文件中检索它,$query=$_GET['value1'];
以便 $query 取值 a。
现在,检查以下内容:
我的 assignastemp 文件中有这行代码,以便我可以检索变量中的教授 ID$query: $query=$_POST['searchprofid'];
在 assignastemp 的操作字段中,我输入了:action= 'sendmail.php?prof_id=$query
' 因为我希望将同一个教授 ID 传递给我的下一个表单 sendmail.php,以便我也可以在 sendmail.php 中显示和使用它。但它没有传递价值。请告诉我正确的语法。
这是我的search.php文件(它工作正常并给了我正确的结果,但没有将 prof_id 传递给 assignastemp.php):
<?php
include('connectionfile.php');
$query=$_POST['searchprofid'];
$query1 = $_POST['searchprofname'];
$query2=$_POST['searchprofdesignation'];
$query3=$_POST['searchprofexperience'];
$query4=$_POST['searchprofemail'];
$query5=$_POST['searchprofcolg'];
$query6=$_POST['searchprofsubject'];
echo "<br><p>";
$raw_results = mysql_query("SELECT * FROM professor WHERE (`prof_id` LIKE '%".$query."%') AND (`prof_name` LIKE '%".$query1."%') AND (`designation` LIKE '%".$query2."%') AND (`experience` LIKE '%".$query3."%') AND (`prof_email_id` LIKE '%".$query4."%') AND (`college_name` LIKE '%".$query5."%') AND (`subject_name` LIKE '%".$query6."%') ") OR die(mysql_error());
$number= mysql_num_rows($raw_results);
echo "<br>No. of results returned: ";
echo "$number";
if($number > 0)
{
echo ( "<form id='assign' action= 'assignastemp.php?prof_id=$query' method='post'> <table border='1' cellpadding='8' cellspacing= '6' bgcolor= 'white' bordercolor='158bee' align='center' >" ) ;
while($results = mysql_fetch_array($raw_results))
{
echo ("<tr><td><p>".$results['prof_id']."</td><td>".$results['prof_name']."</td><td>".$results['designation']."</td><td>".$results['experience']."</td><td>".$results['prof_email_id']."</td><td>".$results['college_name']."</td><td>".$results['subject_name']."</td> ");
echo(" <td><center><input type= 'submit' name='assign' value= 'Assign' /> </td>");
/* echo(" <td><center><input type= 'hidden' name='prof_id' value='prof_id' /> </td>"); */
echo("</p></tr>");
}
echo("</table></form>");
}
else
{
echo "<br> No matches found.";
}
mysql_close($id_link);
?>
Here's **assignastemp.php**:<?php
include('connectionfile.php');
$prof_id= $_POST['prof_id'];
echo("</p> Professor ID: $prof_id");
mysql_close($id_link);
?>