"The PHP portion of the script deals with the information that
is sent by the HTML form that we will look at shortly. It starts by
including the database connection script. This script contains code
that starts a new session and also some other functions that we
will be using: include "connect.php";
"By including this script we make all of its contents available
to the addbookmarks script. Next, we run a check to make sure that
no user accidentally accesses this page and ends up with ugly error
messages that my crash our application. We essentially check to see
if a session variable called uname is set. We could basically use
any of the session variables that are created during that
authentication process:
if(!isset($_SESSION['uname'])){
"If the variable is not set, then we simply send the user to the
login page since it indicates that the user either tried to access
the application by running this script directly without going
through the authentication process or that the user is trying to
break our application. Either way, we stop this illegal entry into
the application by redirecting the user like so:
//redirect to login page
header("location:login/login.php");
}