Ad block is installed and active. Please support us by disabling it.
HomeSaturday, January 20, 2018, 16:52:47
1

Password Protect With PHP

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

PHPBB3 Shoutbox

Vesion: 1.1. Released: 08/08/10, Licence GNU, Price: Free

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.

View content in a zip file with PHP

List all files in a zip archive with PHP

Imageline

Draws a line between the two given points.

Link Base 2.0.

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.

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.

Create dynamic Web Pages with PHP & MySQL

Create dynamic Web Pages with PHP & MySQL, Requirement(s): PHP Server, MySQL

Upload Attachment - PHP Tutorial

Upload attachment with PHP example, 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.