1
$sql = "select * from tbl_pi where patientNumber='" . $pn . "'";
$res = mysql_query($sql);
if (mysql_num_rows($res) == 1) {
    echo '<center>
            <p style="background-color: #ff3333;
               font-family:calibri;
               color:white;
               font-weight: bold;">PATIENT NUMBER ALREADY IN USE!!</p>';
}

after the error detection, the user have no choice but to start over since the previous data entered were all gone or reset.

How can I prevent that from happening?

M. A. Kishawy
  • 5,001
  • 11
  • 47
  • 72
  • [Please, don't use `mysql_*` functions in new code](http://stackoverflow.com/questions/12859942/). They are no longer maintained [and are officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). See the [red box](http://uk.php.net/manual/en/function.mysql-connect.php)? Learn about [*prepared statements*](https://en.wikipedia.org/wiki/Prepared_statement) instead, and use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) - [this article](http://php.net/manual/en/mysqlinfo.api.choosing.php) will help you decide which one is best for you. – John Conde Mar 13 '17 at 13:58
  • You have to send back (you can youse GET params, Session ...) used value ($pn) and fill the textbox with it. – Autista_z Mar 13 '17 at 14:00

0 Answers0