PHP, MySQL and duplicate entry error message
So, I created a query that searched for an entry that matched the POSTED teacher id (the potential duplicate) and returned a die ("It looks like we already have an app on file...") message if the query held a value. If no entry was found, the script continue on its merry way and completed the INSERT into the database.
$colname_get_tid = "1";
$colname_get_tid = $_POST['tid'];
mysql_select_db($database_visions, $visions);
$query_get_tid = sprintf("SELECT tid, stamp FROM app WHERE app.tid = '%s'", $colname_get_tid);
$get_tid = mysql_query($query_get_tid, $visions);
$row_get_tid = mysql_fetch_assoc($get_tid);
$totalRows_get_tid = mysql_num_rows($get_tid);
if ($totalRows_get_tid) {
die ("It looks like we already have an application on file for
teacher $colname_get_tid that was submitted on $time1, $time2 at $time3. Have you completed this application before? Please call us to check on the status or your application, or click the browser's back button and try again.");
}
else do the INSERT...
0 Comments:
Post a Comment
<< Home