Jump to content

creating an error page after form entry


scmeeker

Recommended Posts

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

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");
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.