編集:私は今のところ問題を解決しましたが、別の方法があるかどうか、または以前に機能しなかった理由を誰かが教えてくれる場合はお知らせください!
前のページから 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>
レビュー スケジュール ページのコードは次のとおりです。
<!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">
© Copyright Ryan Strouse ©
</div>
</footer>
</html>
私はそれを考え出した!私が持っている必要があります:
<h3><a href="CourseListings.php?diverID=<?php echo $DiverID;?>">Return to View Course Listings</a></h3>
プレーンリンクの代わりに。誰かがもっと良いものを思いつかない限り?ありのままを受け入れていい気がする