Hi!
I have this little script.. hi.php allows me to enter a name and age. welcome.php echoes back the data added. My question: How do I echo the ID # from the MySQL database? The goal would be to have another cell on the welcome.php table to identify the ID #.
Scripts are below, and thank you in advance!
hi.php:
<html>
<body>
<form action="welcome.php" method="POST">
Enter your name: <input type="text" name="name" />
Enter your age: <input type="text" name="age" />
<input type="submit" />
</form>
</body>
</html>
and welcome.php:
<?
include ("config.php");
$name=$HTTP_POST_VARS['name'];
$age=$HTTP_POST_VARS['age'];
$connection=mysql_connect($hostname, $username, $password)
or die("Could not establish connection");
mysql_select_db($database_name, $connection)
or die ("Could not select database");
$query="INSERT INTO `example` (name, age) VALUES ('".$name."', '".$age."')";
echo $query;
$result=mysql_query($query);
mysql_close($connection);
if (!$result)
{die("<font color=\"red\"><b>Your information COULD NOT be entered into the database\.</font><br>");}
echo "
<TABLE BORDER>
<TR>
<TD COLSPAN='2'>Our records indicate that you are</TD>
</TR>
<TR>
<TD>Name</TD><TD>".$name. "</TD>
</TR>
<TR>
<TD>Age</TD><TD>" .$age. "</TD>
</TR>
<TR>
<TD COLSPAN='2'><a href='hi.php'>Do another!</a></TD>
</TABLE>";
?>
<html>
<body>
</body>
</html>