scmeeker Posted September 6, 2010 Share Posted September 6, 2010 When there is a duplicate entry in my database, I would like it to go to the another page that indicates the error, rather than the "Error: Duplicate entry 'username' for key 1". It happens if someone is going to join and there is a duplicate entry. I would rather it show one of my customized php pages rather than a black page stating the error. I've tried to catch the entry with some php code but it bypasses it and continues with the duplicate error. I would appreciate any direction with this. Thanks! Link to comment https://forums.phpfreaks.com/topic/212677-creating-an-error-page-after-form-entry/ Share on other sites More sharing options...
soycharliente Posted September 6, 2010 Share Posted September 6, 2010 Read this article. Link to comment https://forums.phpfreaks.com/topic/212677-creating-an-error-page-after-form-entry/#findComment-1107875 Share on other sites More sharing options...
scmeeker Posted September 6, 2010 Author Share Posted September 6, 2010 I read through the article but didn't see how I could bypass it to a new custom page. Here is the code I'm using to try to bypass it: <?php include('web_connect.php'); $username = mysql_real_escape_string($_POST[username]); $email = mysql_real_escape_string($_POST[email]); $result = mysql_query("SELECT email, username FROM artist ") or die(mysql_error()); if (mysql_num_rows($result) < 1) { $categoryList = "<p><em>Sorry, no artists.</em></p>"; } else { while ($items = mysql_fetch_array($result)) { $artist_email .= $items['email']; $artist_username .= $items['username']; } } if ($artist_username == $username ) { header("location:join_duplicate_username_error.php"); } Link to comment https://forums.phpfreaks.com/topic/212677-creating-an-error-page-after-form-entry/#findComment-1107971 Share on other sites More sharing options...
scmeeker Posted September 6, 2010 Author Share Posted September 6, 2010 Thanks...I figured it out! Link to comment https://forums.phpfreaks.com/topic/212677-creating-an-error-page-after-form-entry/#findComment-1107986 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.