hi there
I'm setting up a private area for a website, the private area is in php whit the username/password stored in a php file there's no need for a database in mysql.
after trying a lot of different php scripts I found whit this one that suits my case well.
everything is working fine but I would like to add two things, as my new to php I didn't got it working fine
- a logout page that deletes the cookies
- deny the direct acces to protected files if the user is not logged (so I suppose a php control over the cookie)
the script is basically this two php files:
login form
form.php
invia.phpPHP Code:<head>
<title>Private area</title><?
require ("config.php");?>
<link href="form1.css" rel="stylesheet" type="text/css">
<link href="button.css" rel="stylesheet" type="text/css">
<link href="orsa2.css" rel="stylesheet" type="text/css">
<style type="text/css">
.style1 {
font-weight: bold;
text-decoration: underline;
font-size: 17px;
}
</style>
</head>
<div align="center">
<form name="Offmania_Pages_Protected" method="post" action="invia.php">
<table width="<? echo $lunghezza_tabella ?>" border="0" align="center" cellpadding="0" class="tabella">
<tr>
<td><span class="titlefont">Utente</span></td>
</tr>
<tr>
<td>
<input name=primo class="form1" size="<? echo $lunghezza_campo1 ?>" maxlength="<? echo $lunghezza_max_campo1 ?>" style="width: 140px"><br></td>
</tr>
<tr>
<td><span class="titlefont">password</span></td>
</tr>
<tr>
<td>
<input name=secondo type="password" class="form1" size="<? echo $lunghezza_campo2 ?>" maxlength="<? echo $lunghezza_max_campo2 ?>" style="width: 140px"></td>
</tr>
<td><input type="submit" name="Submit" value="Entra" class=button >
<input type="reset" name="Submit2" value="Cancella" class=button >
<?
echo "<input type=hidden name=ipadress value=$REMOTE_ADDR>";
echo "<input type=hidden name=referer value=$HTTP_REFERER>";
echo "<input type=hidden name=ora value=$ora>";
echo "<input type=hidden name=data value=$data>";
?>
</td>
</table></form>
</div>
contains the username/passwords, the link to the protected pages as well the link to the error file
so what part of the php code do I have to change to get that issues fixed?!PHP Code:<title>Private area</title>
<?
require ("config.php");?>
<html><head></head><body margineight="50">
<?
if ($primo == "Admin" and $secondo == "Admin")
{
include ("area/1.php"); ### protected page of the firs user
}
elseif ($primo == "demo" and $secondo == "demo")
{
include ("area/2.php"); ### protected page of the second user
}
########### decommentare (eliminare #) per aumentare le pagina de proteggere naturalmente se ne possono aggiungere altre
###elseif ($primo == "3" and $secondo == "33")
### {
### include ("protette_000p/esempio3.php"); ### indirizzo della pagina da proteggere in cui si accede dopo la login
###}
###elseif ($primo == "4" and $secondo == "44")
### {
### include ("protette_000p/esempio4.php"); ### indirizzo della pagina da proteggere in cui si accede dopo la login
###}
############
else (include "area/err.php"); ### error page
?>
</body></html>
many thanks!!!



Reply With Quote

Bookmarks