Now you can use this script on your website or on any log-in webpage, which you want to secure online. This php script Provides best security along with multiusers & passwords. You can also use this php script without using MySql database.
Code Below for to be secure any page file
Feature: This script has no errors and no security hole,
For example: By using this script you can’t access secured page by pressing the back button, after logging out, which you were able to access earlier.
Code Below for Login.php file
<?php
//simple PHP login script using Session
//start the session * this is important
session_start();
//login script
if(isset($_REQUEST['ch']) && $_REQUEST['ch'] == 'login'){
//give your login credentials here
if(($_REQUEST['uname'] == 'admin' && $_REQUEST['pass'] == 'mypass') or
($_REQUEST['uname'] == 'admin1' && $_REQUEST['pass'] == 'mypass1'))
$_SESSION['login_user'] = 1;
else
$_SESSION['login_msg'] = 1;
}
//get the page name where to redirect
if(isset($_REQUEST['pagename']))
$pagename = $_REQUEST['pagename'];
//logout script
if(isset($_REQUEST['ch']) && $_REQUEST['ch'] == 'logout'){
unset($_SESSION['login_user']);
header('Location:login.php');
}
if(isset($_SESSION['login_user'])){
if(isset($_REQUEST['pagename']))
header('Location:'.$pagename.'.php');
else
header('Location:index.php');
}else{
?>
<title>dSTAR Infotech: Log-In</title>
</head>
<style>
.warn_msg {
font-family: "Segoe UI";
font-size: 12px;
color: #FFFFF0;
background-color: #9D0004;
border-radius:20px;
padding-top: 2px;
padding-bottom: 3px;
}
</style>
<body>
<div class="login-box">
<form action="" method="post" name="form1">
<div class="form_head">
<div align="center">Enter Password to Access this page ! <br />
<br />
<table width="236" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="64" class="word_user_pass"><div align="right">Username</div></td>
<td width="20" align="center">:</td>
<td width="152"><input name="uname" type="text" class="inputbox" id="uname" value="" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><div align="right" class="word_user_pass">Password</div></td>
<td align="center">:</td>
<td><input name="pass" type="password" class="inputbox" id="pass" /></td>
</tr>
<tr>
<td> </td>
<td align="center"> </td>
<td> </td>
</tr>
<tr>
<td colspan="3" align="center"> </td>
</tr>
<tr>
<td colspan="3" align="center"><input name="submit" type="submit" class="button_li" value="Login" /></td>
</tr>
</table>
<span class="warn_msg" style="color:#B8B8B8;">
<?php
//display the error msg if the login credentials are wrong!
if(isset($_SESSION['login_msg'])){
echo ' Wrong username and password ! ';
unset($_SESSION['login_msg']);
}
?>
</span>
<input type="hidden" name="ch" value="login" />
</div>
</div>
</form>
<div align="center"></div>
</div>
<?php } ?>
</body>
</html>
<?php session_start();
//check logged in or not!
if(!isset($_SESSION['login_user'])){
header('Location:dstar_infotech_login.php?pagename='.basename($_SERVER['PHP_SELF'], ".php")); }
?>
Code Below for Logout session
login.php?ch=logout
This link for for destroyed already made session
you can modified this link as per your choice according to login page name
you can modified this link as per your choice according to login page name
5 Comments
html code fine..ok but how to link this code my website please guide me
ReplyDeleteGREAT ;) easy ! love it ♥
ReplyDeleteyou shared a nice information with us and this is very helpful.
ReplyDeletecinema hd on firestick
kırklareli
ReplyDeletetekirdağ
giresun
adıyaman
manisa
SOREN2
Hi thanks for poosting this
ReplyDelete