I'm trying to learn how to get something out of a database and echo it in HTML. I'll post the code, but here's what I'm doing:
Page 1 is a simple form where I enter a value that is already in a test database I'm working with.
Page 2 echos that same value
Page 3 echos that value and looks up the TestKey that for that particular value. I want the TestKey to echo on the page.
I'm able to get pages 1 & 2 to work, but I'm having trouble with page 3. I can get the value to print but I can't get it to look up the TestKey that goes with the value. I'm not getting an error statement either so I'm confused as to what I'm doing wrong.
Any help would be appreciated.
Here's the code for the 3 pages:
PAGE ONE:
<?php
session_start();
session_register('textfield');
?>
<html>
<head>
<title>PAGE ONE</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="testform" method="post" action="testcode.php">
<input type="text" name="textfield">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
PAGE TWO:
<?php
session_start();
session_register("textfield");
?>
<html>
<head>
<title>PAGE TWO</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
session_register("textfield");
{
echo "$textfield
<a href="../lastpage.php'>Continue</a>";
}
exit();
?>
</body>
</html>
PAGE THREE:
<?php
session_start();
?>
<html>
<head>
<title>PAGE THREE</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
echo "$textfield";
@ $db = mysql_connect("X", "X", "X");
if (!$db)
{
echo "Error: Could not connect. Please try again later.";
exit;
}
mysql_select_db("X");
$resultID = mysql_query("SELECT tblTest.TestKey FROM tblTest WHERE tblTest.TestData=$textfield");
while (list($TestKey) = mysql_fetch_row($resultID))
$result = mysql_query($query) or die("Invalid query: " . mysql_error());
{
echo
"$TestKey";
}
mysql_close($linkID);
?>
</body>
</html>