tags:

views:

58

answers:

1
+2  A: 

Note: This script, as-is, is vulnerable to sql-injections. The code that follows is not dealing with this, as it's out of the scope of the original question. Do not use this code as-is in a production environment.

You have a small problem jumping from PHP to HTML:

<?php

   mysql_select_db("Hospital", $con) or die(mysql_error());
   $fname = $_POST["fname"];
   $result = mysql_query("SELECT HOSPNUM FROM t2 WHERE FIRSTNAME='{$fname}'");

?>

<h3>Results:</h3>

<?php while ( $row = mysql_fetch_array($result) ) { ?>

  <input type="text" name="hnum" value="<?php echo $row["HOSPNUM"]; ?>" />

<?php } ?>
Jonathan Sampson
Also should be noted, unless they are filtering the superglobals, there is a SQL injection vulnerability.
alex