First, just so we are on the same page, isset($_GET['urlName']) is true in all of the below cases:
1. /eliteparty.php?urlName=thebutteryflylounge
2. /eliteparty.php?urlName=thebutteryflyloung
3. /eliteparty.php?urlName=
4. /eliteparty.php?urlName
So in any of these cases, your redirect code is not being executed.
if (!isset($_GET['urlName'])){
//redirect code here
}
Since isset($_GET['urlName']) is true, your select query is run, which searches the guestlist table for whatever $urlName is set to. If you misspell
the url name, or leave it blank, you're not gonna get any results right?
As a result, everything inside the if (mysql_num_rows($result)) block is gonna
get skipped, because mysql_num_rows($result) will be 0.
Note that just about all of your html is inside that block, with the exception of the last 3 lines. (View source on the "empty page" and you will see those last 3 lines.)
If you nest the brackets { with tabs it might help you see whats going on.
What you might want to consider, in addition to what halojoy mentioned, is waiting to decide whether or not to redirect until after you know if the page exists or not.
IE:
$pageExists = 0;
if (isset($_GET['urlName']))
{
//check if page exists...etc
$pageExists = mysql_num_rows($result);
}
if ($pageExists)
{
//output all the html for the page
}
else
{
//redirect
}