Ad block is installed and active. Please support us by disabling it.
HomeSunday, November 19, 2017, 14:11:19
1

Password Protect With PHP

Tuesday, February 10, 15, 09:49:11, 3 Yaers Ago Via wain, Hits: 2967
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

PHP filesize

The filesize function returns the size of the specified file.

Captcha V2 - Free PHP Script

PHP Captcha protection image Version 2, - Requirement(s): PHP Server, GD Library

Contact Us 2.0. :: PHP Form

Version 2.0. - A contact us form with email and form field validation. It allows your visitors to send you an email directly from your website.

How to set up password for phpMyAdmin in Wamp Server

Password for phpMyAdmin in Wamp

RSS, MySQL & Smarty

Smarty > Publishing MySQL Data in RSS 2.0

Creating a CAPTCHA with PHP :: PHP Tutorial

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

Adsense crawler errors and robots.txt

How to fix Google AdSense crawler errors in robots.txt

Imageline

Draws a line between the two given points.

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.

Creating a Math CAPTCHA with PHP - PHP Tutorial

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

wain

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