Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为页面检查存储值,导航到下一页,然后通过链接返回失败_Php_Mysql_Mysqli - Fatal编程技术网

Php 为页面检查存储值,导航到下一页,然后通过链接返回失败

Php 为页面检查存储值,导航到下一页,然后通过链接返回失败,php,mysql,mysqli,Php,Mysql,Mysqli,编辑:我现在已经解决了这个问题,但是如果有人能告诉我是否有其他方法,或者为什么它以前不起作用,请告诉我 我有一个页面正在接收上一页的id,根据该id,您可以查看一个人的课程表。我在“课程计划”页面上添加了一个链接,将它们带回“注册课程”页面,但每次没有id时,我都会收到一个错误。我将id存储在一个隐藏字段中,但由于某些原因,它不会随链接一起传递。不确定为什么没有传递该值,因为它与其他页面的代码相同。谢谢你的帮助 以下是注册页面的代码: <!DOCTYPE html PUBLIC "-//W

编辑:我现在已经解决了这个问题,但是如果有人能告诉我是否有其他方法,或者为什么它以前不起作用,请告诉我

我有一个页面正在接收上一页的id,根据该id,您可以查看一个人的课程表。我在“课程计划”页面上添加了一个链接,将它们带回“注册课程”页面,但每次没有id时,我都会收到一个错误。我将id存储在一个隐藏字段中,但由于某些原因,它不会随链接一起传递。不确定为什么没有传递该值,因为它与其他页面的代码相同。谢谢你的帮助

以下是注册页面的代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Course Listings</title>
<link rel="stylesheet" href="php_styles.css" type="text/css" />
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1>Aqua Don's Scuba School</h1>
<h2>Class Registration Form</h2>
<?php
$DBConnect = @mysqli_connect("localhost", "students", "password")
    Or die("<p>Unable to connect to the database server.</p>"
    . "<p>Error code " . mysqli_connect_errno()
    . ": " . mysqli_connect_error()) . "</p>";
$DBName = "scuba_school";
@mysqli_select_db($DBConnect, $DBName)
    Or die("<p>Unable to select the database.</p>"
    . "<p>Error code " . mysqli_errno($DBConnect)
    . ": " . mysqli_error($DBConnect)) . "</p>";
$DiverID = $_GET['diverID'];
if (empty($DiverID))
    exit("<p>You must enter a diver ID! Click your browser's Back button to return to the previous page.</p>");
$TableName = "divers";
$SQLstring = "SELECT * FROM $TableName WHERE diverID='$DiverID'";
$QueryResult = @mysqli_query($DBConnect, $SQLstring)
    Or die("<p>Unable to execute the query.</p>"
    . "<p>Error code " . mysqli_errno($DBConnect)
    . ": " . mysqli_error($DBConnect)) . "</p>";
if (mysqli_num_rows($QueryResult) == 0)
    die("<p>You must enter a valid diver ID! Click your browser's Back button to return to the Registration form.</p.");
mysqli_close($DBConnect);
?>
<form method="get" action="ReviewSchedule.php">
<p><strong>Student ID: <?= $DiverID ?></strong>
<input type="submit" value=" Review Current Schedule " /><input type="hidden" name="diverID" value="<?= $DiverID ?>" /></p>
</form>
<form method="get" action="RegisterDiver.php">
<p><strong>Select the class you would like to take:</strong><br />
<input type="radio" name="class" value="Beginning Open Water" checked="checked" />Beginning Open Water<br />
<input type="radio" name="class" value="Advanced Open Water" />Advanced Open Water<br />
<input type="radio" name="class" value="Rescue Diving" />Rescue Diving<br />
<input type="radio" name="class" value="Divemaster Certification" />Divemaster Certification<br />
<input type="radio" name="class" value="Instructor Certification" />Instructor Certification</p>
<p><strong>Available Days and Times:</strong><br />
<select name="days">
<option selected="selected" value="Mondays and Wednesdays">Mondays and Wednesdays</option>
<option value="Tuesdays and Thursdays">Tuesdays and
Thursdays</option>
<option value="Wednesdays and Fridays">Wednesdays and
Fridays</option>
</select>
<select name="time">
<option selected="selected" value="9 a.m. - 11 a.m.">9 a.m. - 11 a.m.</option>
<option value="1 p.m. - 3 p.m.">1 p.m. - 3 p.m.</option>
<option value="6 p.m. - 8 p.m.">6 p.m. - 8 p.m.</option>
</select><input type="hidden" name="diverID" value="<?= $DiverID ?>" /></p>
<p><input type="submit" value=" Register " action="RegisterDiver.php"/>
<input type="reset" /></p>
</form>
</body>
<footer>
<div align="center">
    <a href="Registration.html">Return to Registration</a>
    <br/>
    <a href="../Menu.html">Return to Menu</a>
</div>
</footer>
</html>

课程表
水上潜水学校
班级登记表

使用POST而不是GET

我个人的经验法则是:发布表单,获取通过URL传递的变量

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Review Schedule</title>
<link rel="stylesheet" href="php_styles.css" type="text/css" />
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1>Aqua Don's Scuba School</h1>
<h2>This is your current schedule:</h2>
<?php
$DiverID = $_GET['diverID'];
if (empty($DiverID))
    exit("<p>You must enter a diver ID! Click your browser's Back button to return to the previous page.</p>");
$DBConnect = @mysqli_connect("localhost", "students","password")
    Or die("<p>Unable to connect to the database server.</p>"
    . "<p>Error code " . mysqli_connect_errno()
    . ": " . mysqli_connect_error()) . "</p>";
$DBName = "scuba_school";
@mysqli_select_db($DBConnect, $DBName)
    Or die("<p>Unable to select the database.</p>"
    . "<p>Error code " . mysqli_errno($DBConnect)
    . ": " . mysqli_error($DBConnect)) . "</p>";
$TableName = "registration";
$SQLstring = "SELECT * FROM $TableName WHERE diverID='$DiverID'";
$QueryResult = @mysqli_query($DBConnect, $SQLstring)
    Or die("<p>Unable to execute the query.</p>"
    . "<p>Error code " . mysqli_errno($DBConnect)
    . ": " . mysqli_error($DBConnect)) . "</p>";
if (mysqli_num_rows($QueryResult) == 0)
    die("<p>You have not registered for any classes! Click your browser's Back button to return to the previous page.</p>");
echo "<table width='100%' border='1'>";
echo "<tr><th>Class</th><th>Days</th>
<th>Time</th></tr>";
$Row = mysqli_fetch_assoc($QueryResult);
do {
    echo "<tr><td>{$Row['class']}</td>";
    echo "<td>{$Row['days']}</td>";
    echo "<td>{$Row['time']}</td></tr>";
    $Row = mysqli_fetch_assoc($QueryResult);
} while ($Row);

?>


<form method="get" action="CourseListings.php">
<input type="hidden" name="diverID" value="<?= $DiverID ?>" />
<center>
<h3><a href="CourseListings.php">Return to View Course Listings</a></h3>
<h3><a href="Registration.html">Go back to Registration</a></h3>
<h3><a href="../Menu.html">Return to Menu</a></h3>
</center>
</form>

<?php
mysqli_free_result($QueryResult);
mysqli_close($DBConnect);
?>


</body>
<footer>
<div align="center">
&copy; Copyright Ryan Strouse &copy;
</div>
</footer>
</html>
<h3><a href="CourseListings.php?diverID=<?php echo $DiverID;?>">Return to View Course Listings</a></h3>