程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了使用if(isset($ _ POST ['submit']))不能在打开脚本时显示回显大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决使用if(isset($ _ POST ['submit']))不能在打开脚本时显示回显?

开发过程中遇到使用if(isset($ _ POST ['submit']))不能在打开脚本时显示回显的问题如何解决?下面主要结合日常开发的经验,给出你关于使用if(isset($ _ POST ['submit']))不能在打开脚本时显示回显的解决方法建议,希望对你解决使用if(isset($ _ POST ['submit']))不能在打开脚本时显示回显有所启发或帮助;

您需要给提交<input>的名称起个名字,否则将无法使$_POST['submit']

<p><input type="submit" value="submit" name="submit" /></p>

解决方法

我的if(isset($_POST['submit']))代码有一点问题。我想要的是一些回声,并且在打开脚本时不显示表格,但是我希望在单击表单的提交按钮时显示该表格。问题是,当包含if(isset($_POST['submit']))函数时,当我单击“提交”按钮时,它根本不显示回显和表格。为什么会这样,请您帮我解决这个问题。

下面是代码:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>Exam Interface</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>

<p><strong>NOTE: </strong>If a search box is left blank,then the form will search for all data under that specific field</p>

<form action="exam_interface.php" method="post" name="sessionform">        <!-- This will post the form to its own page"-->
<p>Session ID: <input type="text" name="sessionid" /></p>      <!-- Enter Session Id here-->
<p>Module number: <input type="text" name="modulEID" /></p>      <!-- Enter Module Id here-->
<p>Teacher Username: <input type="text" name="TEACHERID" /></p>      <!-- Enter Teacher here-->
<p>student Username: <input type="text" name="studentid" /></p>      <!-- Enter User Id here-->
<p>Grade: <input type="text" name="grade" /></p>      <!-- Enter Grade here-->
<p>Order Results By: <SELEct name="order">
<option value="ordersessionid">Session ID</option>
<option value="ordermodulEID">Module number</option>
<option value="orderTEACHERID">Teacher Username</option>
<option value="orderstudentid">student Username</option>
<option value="ordergrade">Grade</option>
</SELEct>
<p><input type="submit" value="Submit" /></p>
</form>

<?php

$username="xxx";
$password="xxx";
$database="mobile_app";

mysql_connect('localhost',$username,$password);

@mysql_SELEct_db($databasE) or die("Unable to SELEct database");

$sessionid = isset ($_POST['sessionid']) ? $_POST['sessionid'] : "";
$modulEID = isset ($_POST['modulEID']) ? $_POST['modulEID'] : "";
$TEACHERID = isset ($_POST['TEACHERID']) ? $_POST['TEACHERID'] : "";
$studentid = isset ($_POST['studentid']) ? $_POST['studentid'] : "";
$grade = isset ($_POST['grade']) ? $_POST['grade'] : "";
$orderfield = isset ($_POST['order']) ? $_POST['order'] : "";

$sessionid = mysql_real_escape_String($sessionid);
$modulEID = mysql_real_escape_String($modulEID);
$TEACHERID = mysql_real_escape_String($TEACHERID);
$studentid = mysql_real_escape_String($studentid);
$grade = mysql_real_escape_String($gradE);

switch ($orderfield) {
    case 'ordersessionid': $orderfield = 'gr.SessionId';
    break;
    case 'ordermodulEID': $orderfield = 'm.ModulEID'; 
    break;
    case 'orderTEACHERID': $orderfield = 's.TEACHERID';
    break;
    case 'orderstudentid': $orderfield = 'gr.studentId'; 
    break;
    case 'ordergrade': $orderfield = 'gr.Grade';
    break;
}

$ordertable = $orderfield;

$result = mysql_query("SELECT * FROM Module m INNER JOIN Session s ON m.ModulEID = s.ModulEID JOIN Grade_Report gr ON s.SessionId = gr.SessionId JOIN student st ON gr.studentId = st.studentId WHERE ('$sessionid' = '' OR gr.SessionId = '$sessionid') AND ('$modulEID' = '' OR m.ModulEID = '$modulEID') AND ('$TEACHERID' = '' OR s.TEACHERID = '$TEACHERID') AND ('$studentid' = '' OR gr.studentId = '$studentid') AND ('$grade' = '' OR gr.Grade = '$grade') ORDER BY $ordertable ASC");

$num=mysql_numrows($result);

if(isset($_POST['submit'])){

echo "<p>Your Search: <strong>Session ID:</strong> "; if (empty($sessionid))echo "'All Sessions'"; else echo "'$sessionid'";echo ",<strong>Module ID:</strong> "; if (empty($modulEID))echo "'All Modules'"; else echo "'$modulEID'";echo ",<strong>Teacher Username:</strong> "; if (empty($TEACHERID))echo "'All Teachers'"; else echo "'$TEACHERID'";echo ",<strong>student Username:</strong> "; if (empty($studentid))echo "'All students'"; else echo "'$studentid'";echo ",<strong>Grade:</strong> "; if (empty($gradE))echo "'All Grades'"; else echo "'$grade'"; "</p>";

echo "<p>number of Records Shown in Result of the Search: <strong>$num</strong></p>";

echo "<table border='1'>
<tr>
<th>student Id</th>
<th>Forename</th>
<th>Session Id</th>
<th>Grade</th>
<th>Mark</th>
<th>Module</th>
<th>Teacher</th>
</tr>";

while ($row = mysql_fetch_array($result)){

 echo "<tr>";
  echo "<td>" . $row['studentId'] . "</td>";
  echo "<td>" . $row['Forename'] . "</td>";
  echo "<td>" . $row['SessionId'] . "</td>";
  echo "<td>" . $row['Grade'] . "</td>";
  echo "<td>" . $row['Mark'] . "</td>";
  echo "<td>" . $row['Modulename'] . "</td>";
  echo "<td>" . $row['TEACHERID'] . "</td>";
  echo "</tr>";
}

echo "</table>";

}

mysql_close();


 ?>

</body>
</html>

任何帮助将不胜感激,谢谢。

大佬总结

以上是大佬教程为你收集整理的使用if(isset($ _ POST ['submit']))不能在打开脚本时显示回显全部内容,希望文章能够帮你解决使用if(isset($ _ POST ['submit']))不能在打开脚本时显示回显所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。