Web App Html Xmlns Server Username Membership Database Blackberry 2.6. 2.62 Nuances Content Management System Divs Php Mysql Gsa Gov Longest Time Time Web Intranet Information Systems Free App Tip Branding Csv Doctype University Web Firefox Search Engine Optimization AJAX Social Networking Php Echo Php Database Index Design Double Benefit Video And Multimedia Headaches Database Functionality rss tricks Google CMS Ektron Traveling Tag Stylesheet Marketing organization Asynchronous Javascript And Xml Last Straw Export Ideas Area 51 Football Game Web Development Php Variables Telegraph Web Development Html Tag 26b Membership Login Email Settings Phpmyadmin Css Files PHP Tips Laserjet 4100 tips Strategy Deans List Div Id Honesty Php Password Lt World Wide Web W3c Array Hourly Rates 2.1 Nate Web Developer Color Scheme Indexing Services Import SEO Time Frame blog free templates encryption Bandwidth Usage XML css Variables Config Php Hourly Fee Working With Clients Mysql Num Rows Database Import Cms Content News Releases Variation developer Php File Transparent Image Images Links Import Functionality Full Time Fellow Web Lot System Administrator Addressbook Login Php Address Book Sql Server Insanity Web Applications Integrity Federal Employees Br Mumbo Jumbo Color Schemes Mobile Platforms Download Microsoft Telecommunications Products Web Developers Screen Resolutions Dynamic Css tools Echo Select Name View Source database develop Sql Database Joomla Gsa includes Categories steps Mysql Fetch Array Lotus Css File Information Technology Products Div Rant Internet Explorer Accurate Time Colors Dashboard Strange Person Capital Letters Husker Football SQL Software Applications WordPress PHP Server Hostname Password Reset Forefront Lotus Notes Reference Free Download Internet Explorer 7 Page Password Cat Id Habit Section 508 New Features Portable Computers Term Relationships Search Google Military Installation Borders Templates Transitional Dtd Gods Gift Web Design redirect Adminemail Transition Email Account Work Log Formatting box model mySQL Page Rank Seo Search Engine Optimization Services Software Multimedia Products
Web App Html Xmlns Server Username Membership Database Blackberry 2.6. 2.62 Nuances Content Management System Divs Php Mysql Gsa Gov Longest Time Time Web Intranet Information Systems Free App Tip Branding Csv Doctype University Web Firefox Search Engine Optimization AJAX Social Networking Php Echo Php Database Index Design Double Benefit Video And Multimedia Headaches Database Functionality rss tricks Google CMS Ektron Traveling Tag Stylesheet Marketing organization Asynchronous Javascript And Xml Last Straw Export Ideas Area 51 Football Game Web Development Php Variables Telegraph Web Development Html Tag 26b Membership Login Email Settings Phpmyadmin Css Files PHP Tips Laserjet 4100 tips Strategy Deans List Div Id Honesty Php Password Lt World Wide Web W3c Array Hourly Rates 2.1 Nate Web Developer Color Scheme Indexing Services Import SEO Time Frame blog free templates encryption Bandwidth Usage XML css Variables Config Php Hourly Fee Working With Clients Mysql Num Rows Database Import Cms Content News Releases Variation developer Php File Transparent Image Images Links Import Functionality Full Time Fellow Web Lot System Administrator Addressbook Login Php Address Book Sql Server Insanity Web Applications Integrity Federal Employees Br Mumbo Jumbo Color Schemes Mobile Platforms Download Microsoft Telecommunications Products Web Developers Screen Resolutions Dynamic Css tools Echo Select Name View Source database develop Sql Database Joomla Gsa includes Categories steps Mysql Fetch Array Lotus Css File Information Technology Products Div Rant Internet Explorer Accurate Time Colors Dashboard Strange Person Capital Letters Husker Football SQL Software Applications WordPress PHP Server Hostname Password Reset Forefront Lotus Notes Reference Free Download Internet Explorer 7 Page Password Cat Id Habit Section 508 New Features Portable Computers Term Relationships Search Google Military Installation Borders Templates Transitional Dtd Gods Gift Web Design redirect Adminemail Transition Email Account Work Log Formatting box model mySQL Page Rank Seo Search Engine Optimization Services Software Multimedia Products

As a final part of a three part series in how to password protect your pages with your new user database that you created from the previous posts. To do this, create a new php file called:

passprotect.php

<?php
include ‘config.php’;
$authorid = $_COOKIE["member"];
$password = $_COOKIE["memberpass"];
$SQLvalidate = “SELECT * FROM `member` WHERE memberid=’$memberid’ AND password=’$password’”;
$results = mysql_query($SQLvalidate);
$numrows = mysql_num_rows($results);
if ($numrows == 0) {
include ‘login.php’;
 die();
}

?>

You may notice a cookie is requested that has not been previously mentioned in other posts. To password protect your pages, it is better to reference a password and memberid comination to prevent unauthorized access. To declare this cookie simply add this line next to the authorid cookie declaration.

setcookie(“memberpass”,”$password”, time()+3600 *2, “/”, “.blazekwebdesign.com”);

Now if you want to password protect a page simply add this line to the top of any page, but make sure you do not have the “include ‘config.php’” before or after because that file is already included in my previous examples and will cause an error. Otherwise, just add this line to THE TOP of any file you want to password protect:

include ‘passprotect.php’;

This is very straight forward, but effective and it is meant to be used in conjunction with the previous posts.

Part 1: How to create a PHP membership database

Part 2: Membership login and password reset in PHP

Part 3: Password Protect your pages in PHP

No comments yet.

Would you like to login?