PHP login problem [txt save data]

Source: Internet
Author: User

<?php
if ($_server [' Request_method ']== ' POST ') {
Get UserNames and Passwords.
$Logi = File ("Users/log.txt");
Work out how many there are
$size = sizeof ($Logi);
Break apart passwords and usernames
foreach ($Logi as $Key => $Val)
{$Data [$Key] = explode ("| |", $Val);}
Run through list and if any match
for ($K = 0; $K < $size; $K + +)
{
$user = $Data [$K] [0];
$pass = $Data [$K] [1];
If Match set cookie and redirect.
if ($user = = Trim (addslashes ($_post ["User"]) && $pass = = Trim (addslashes ($_post ["Pass"]))
{
Setcookie ("In", 1, Time () + 3600);
Start hidden page
Header ("Location:www.111cn.net");
}
}
echo "Login Failed."
If you are didnt log in show login form
else {?>
<div style= "width:250px" >
<div><strong>black Sheep E-team login</strong></div>
<div><form name= "Login" method= "post" action= "<?=$_server [' php_self '];?>" >
<div align= "Right" >username:
<input name= "User" type= "text" >
<br>
Password:
<input name= "pass" type= "password" >
<br>
<input type= "Submit" name= "submit" value= "Submit" >
</div>
</form>
</div></div>
<?php
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.