You are here: Re: Looking for a login script « PHP Programming Language « IT news, forums, messages
Re: Looking for a login script

Posted by J. Frank Parnell on 08/17/07 17:50

On Fri, 17 Aug 2007 12:27:03 GMT, "Serious_Practitioner"
<Serious_PractitionerNOSPAM@att.net> wrote:

>(Also posted to alt.php on 16 Aug 07)
>
>Good day -
>
>I am looking for a log-in script


script you want to protect:
if ($_GET['user']){
include 'loginscript.php';
securityCheck($_GET['user']);
}


loginscript.php:
<?php

function securityCheck($user){

$nodirectaccess = 1;
include 'config/passwords.php';
//passwords.php:
//if ($nodirectaccess != 1){die();}
//$admin = 'bob';
//$passwords[$admin] = 'secretpassword';
//$passwords[USER] = 'PASS';
//$passwords['user1'] = 'test1';

$userpassword = $passwords[$user];


if ( (!isset($_POST["user"])) OR (!isset($_POST["userpassword"]))){$tests
='nottaken';}

if (($_POST["user"] == $user) AND ($_POST["userpassword"] == $userpassword))
{ setcookie("password", $userpassword, time()+60*60*24*2999,
"/");//--sec*min*hour*days
$tests ='good';}

if (($_COOKIE["password"] == $userpassword)AND(isset($_COOKIE["password"]))){
$tests='good';}
// or admin
if (($_POST["user"] == $admin) AND ($_POST["userpassword"] ==
$passwords[$admin]))
{ setcookie("password", $passwords[$admin], time()+60*60*24*2999,
"/");//--sec*min*hour*days
$tests ='good';}

if (($_COOKIE["password"] ==
$passwords[$admin])AND(isset($_COOKIE["password"]))){
$tests='good';}
// end or admin




if ($tests !='good'){
echo '<br /><br /><br />';

if ($tests !='nottaken'){echo "Sorry, you've entered the wrong info. ";}
echo '
<form action="'.$_SERVER['REQUEST_URI'].'" method="post"
name="the_form">
user name: <input type="text" name="user" size="8"
id="name"><br><br>
password: <input name="userpassword" type="text"
size="8">
<br>then <input name="submit" type="submit" value="click
here" >
</form><br>
<br>
If you have cookies enabled in your browser, you will
not have to login unless you delete your cookies.
<br /><br /><br /></div>

<script language="JavaScript"><!--
document.getElementById(\'name\').focus();
//--></script>
';
die;
}
}// end func securityCheck()

?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация