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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.