Ad block is installed and active. Please support us by disabling it.
HomeThursday, September 21, 2017, 03:15:42
1

Password Protect With PHP

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

MySQL to RSS

Publishing MySQL data in RSS

Random MySQL Query

Random MySQL query, requirement(s): PHP Server, MySQL

Filter Words in PHP - PHP Tutorial

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

Send This Link PHP Script

A popup form which allows your visitors to send a referral link from your site. It features admin notification and HTML output.

HTML Button Generator

This script will allow your visitors to create HTML Buttons online. To use the "html button generator" script completely free , the "powered by" link at the bottom of the pages must stay intact.

FeedBack Form with Captcha

It allows your visitors to send you an email directly from your website.

PHP Str_replace - PHP Tutorial

This function returns a string or an array with all occurrences of search in subject replaced with the given replace value.

Jquery PHP Contact Form

This script allows your visitors to send you an email directly from your website.

Timed Redirect JavaScript

Timed redirect javaScript/PHP example

PHP Form Action Self Submit

PHP form action self submit tutorial, requirement(s): PHP server
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.