It is currently June 28, 2017, 01:21:08 PM




Post new topic Reply to topic  [ 1 post ] 
 [PHP] Login system 
Author Message
Newcomer
User avatar

Joined: May 24, 2007, 10:01:08 AM
Posts: 46
Location: Brazil
Character: Adrena
Clan: Adepts of the Cult
Post [PHP] Login system
Don't use db so it's not safe...
Just to show how it works, don't screw all it up haha
PS: (it is in portuguese so if you don't understand something post here and i'll explain :))

PSĀ²: LOGIN = admin
Email = admin@adrena.gov

First: Save as Login.php
Code:
<html>
<title>:: Login ::</title>

<body text="#000000" bgcolor="#C0C0C0">
<?
if($_GET["erro"]=="1"){
   echo "Login or password is incorrect, Try again!";
}
?>
<form method="POST" action="verify.php">
<div align="center">
  <center>
  <p>&nbsp;</p>
  </center>
</div>
<p align="center"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font size="5" face="Courier New">&nbsp;&nbsp; </font>
<font face="Verdana" color="#FF0000"><font size="2"><b>:: </b></font><b>
<font size="2">Administration ::</font></b></font></p>
<p align="center"> <b><font face="Courier New" size="4">&nbsp;&nbsp; Login: </font></b>
<input type="text" name="nome" size="20"></p><p align ="center">
<b><font size="4" face="Courier New">&nbsp; Email: </font></b>&nbsp;<input type="text" name="email" size="30"></p><p align ="center">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" value="ENVIAR" name="ENVIAR"></p><p align ="center">
&nbsp;</p>

</form>
<p align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color="#0000FF">&nbsp; </font><b>
<font face="Verdana" size="1" color="#0000FF">By Adrena a.k.a Felipe, This login system is not safe. it's just to show how it works.!</font></b></p>
</body>
</html>


Second: Save as restrict.php
Code:
<?

session_start();
if(!IsSet($_SESSION["nome"]) || !IsSet($_SESSION["email"])){
   echo "RESTRICTED.";
   exit;
}


?>
<style type="text/css">
<!--
.style1 {
   font-family: Verdana, Arial, Helvetica, sans-serif;
   font-weight: bold;
   font-size: 36px;
   color: #666666;
}
-->
</style>
<title>Welcome!</title>
<body bgcolor="#C0C0C0">

<p align="center"><span class="style1"> <font color="#000000">Welcome NAME.</font></span></p>
<p align="center"><span class="style1"><font size="3">-&gt; Login System &lt;-</font></span></p>
<p align="center"><span class="style1">
<font face="Verdana" size="1" color="#FF0000">By Adrena a.k.a Felipe, This login system is not safe. it's just to show how it works.!</font></span></p>


Third: Save as verify.php
Code:
<?

$nome=$_POST["nome"];
$email=$_POST["email"];


if(empty($nome) || strlen($nome)<5){
   echo "You got to write the name!";
      exit;
}

if(empty($email) || strlen($email)<5 || strstr($email,"@")==FALSE){
   echo "You got to write the email!";
      exit;
}

if(IsSet($_COOKIE["login"])){
   $login=$_COOKIE["login"];
}

if (IsSet ($_COOKIE["pass"])){
   $pass=$_COOKIE["pass"];
}

if($nome=="admin" && $email=="admin@adrena.gov"){
session_start();
$_SESSION["logado"]=TRUE;
$_SESSION["nome"]=$nome;
$_SESSION["email"]=$email;

setcookie("login",$nome,time()+172800);
setcookie("pass",$email,time()+172800);

header("Location: restrict.php");

}else{
   header("Location: login.php?erro=1");
}

?>


Have fun! :puke:

_________________
[img:350:150]http://img70.imageshack.us/img70/6940/adrenadragonbv2.jpg[/img]


December 27, 2007, 07:08:53 PM
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.