*a constant parallactic paradox, sublime*


This post was originally titled "PHP Developer Essentials" which was what I really wanted to post instead of "PHP Essentials". But as I was at it, I got really bored and I realize, I really just wanted to list all my favorite or let me just say "mostly used" php functions.

But to preserve the efforts, let me just leave what I have already typed here—Creating a session with PHP.

Creating a Session


$login_name = $_POST[‘username’];
$login_password = $_POST[‘password’];
if($login_name==’admin’ && $login_password==’@dm!n’){
   $_SESSION[‘user’] = $_POST[‘username’];
   header("Location: ‘home.html’");
   die("Authentication Failed");

What this simple program does, is get post data from a form that uses the POST method and defined the URL of this code as the form target. The form will look like:

<form action=’login.php’ method=’post’>
Username: <input type=’text’ name=’username’>
Password: <input type=’password’ name=’password’>
<input type=’submit’ value=’Login’>

After retrieving post data, it will validate the user inputs then start a session and store the login data (username) in a session variable called (user). It will then set the window location to the home page using the header() function.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s