Ad block is installed and active. Please support us by disabling it.
HomeWednesday, April 25, 2018, 08:54:47
1

Password Protect With PHP

Tuesday, February 10, 15, 09:49:11, 3 Yaers Ago Via wain, Hits: 5983
Password protect tith PHP - tutorial
Example:

index.php

Code:
<?php session_start();
$mypass = 'pass';
if(isset($_POST['Submit'])){
$ccpass = $_POST['password'];
$ccpass = addslashes($ccpass);
if(preg_match('#[^A-Za-z0-9-]#', $ccpass)) { echo "Illegal Characters"; Die();}
if($ccpass == $mypass) {
session_regenerate_id();
$_SESSION['INC_PASS_WORD'] = $ccpass;
session_write_close();
header("location: mypage.php");
exit();
}else{
echo "Login failed";
exit();
}
}else{
?>
<form action="sign_in.php" name="ccform" method="post">
Please enter your password
<br />Password <br />
<input name="password" size="30" type="password" /><br />
<input type="submit" value="Sign In" name="Submit" type="button">
</form>
<?php } ?>


mypage.php

Code:
<?php session_start();
if(!isset($_SESSION['INC_PASS_WORD']) ||
(trim($_SESSION['INC_PASS_WORD'])=='')) {
header("location: sign_in.php");
exit();
}
echo "<h2>My Page</h2>";
?>

Sign In

Sponsor

Related

Email to Friend - PHP Script

This form allows your visitors to suggest your site to a friend. It features an HTML email format and an admin notification email.

PHP Links Script 1.1.

This script allows you to manage your links using a MySQL database. It features easy install, user submission, and an admin panel to add, edit and remove categories and links. The script is easy to customize to suit your needs.

Preg_Match - PHP Email Validation

Validate email with preg_match in php

Adsense crawler errors and robots.txt

How to fix Google AdSense crawler errors in robots.txt

Filter Words in PHP - PHP Tutorial

Filter bad words in PHP, requirement(s): PHP server

PHP form with file upload

Advanced Contact Form with email and form field validation. It allows your visitors to send you an email directly from your website.

Bookmark Current Page - PHP Tutorial

Bookmark current page with PHP example.

Site Recommendation

This script will allow your visitors to recommend your site to their friends.

Creating a Math CAPTCHA with PHP - PHP Tutorial

This tutorial will show you how to create a form with Math Captcha.

PHP Jquery Form

PHP Jquery Form allow your visitors to contact you directly from your website.
About Author

wain

Date Registered: Sun, Feb 8, 15
Last Time Online: Sun, Mar 18, 18
So far has created 115 entries.
wain
This author has not yet filled in any details.