Ciao a tutti, una serie di problemini su di un accesso ad una pagina di amministrazione.
vi spiego meglio
ho una pagina chiamata accept.php dove inserisco la username e la password
Accept.php
PHP:
<TABLE cellSpacing=0 cellPadding=0 border=0 align="center">
<TR>
<TD align=middle>
<TABLE class=stile cellSpacing=1 cellPadding=0 width=300 border=0 height="198">
<TR>
<TD align=middle height="18">
<TABLE class=stile borderColor=#ffffff cellSpacing=10 cellPadding=0 width="100%" bgColor=#dddddd border=1>
<TR>
<TD class=stile borderColor=#000dcb align=middle height=30>
<font face="Bookman Old Style">Autenticazione richiesta</font>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD height="147" valign="top">
<TABLE class=stile cellSpacing=10 cellPadding=0 width="100%" bgColor=#dddddd border=0>
<FORM action="login.php" method="post">
<TR>
<TD align=middle colSpan=2> </TD>
</TR>
<TR>
<TD class=stile align=right><FONT color=#000dcb>
<font face="Bookman Old Style" size="2">Username</font>:</FONT>
</TD>
<TD><INPUT type="text" name="txtuser" class="inputText" size="20">
</TD>
</TR>
<TR>
<TD class=stile align=right><FONT color=#000dcb>
<font face="Bookman Old Style" size="2">Password</font>:</FONT>
</TD>
<TD>
<INPUT type="password" name="txtpassword" class="inputText" size="20">
</TD>
</TR>
<TR align=middle>
<TD colSpan=2 height=50><font face="Bookman Old Style"><INPUT type="submit" value="Accedi"></font>
</TD>
</TR>
</FORM>
</TABLE>
</TD>
</TR>
<tr>
<?php
if(isset($_GET['msg']))
{
echo "<td align='center'><font face='Palatino Linotype' size='2' color='#FF0000'>" . $_GET['msg'] . "</font></td>";
}
?>
</tr>
</TABLE>
</TD>
</TR>
</TABLE>
poi ho la pagina login.php che dovrebbe controllare i dati inseriti in accept.php
Login.php
PHP:
session_start();
require 'Config.php';
require 'Connect.php';
if(isset($_POST['txtuser']))
{
$username=$_POST['txtuser'];
$password=$_POST['txtpassword'];
$username=htmlspecialchars($username);
$password=htmlspecialchars($password);
$username=mysql_real_escape_string($username);
$password=mysql_real_escape_string($password);
if($username=="")
{
$messaggio=urlencode("Non hai inserito la username");
header('location:'.'accept.php'.'?msg='.$messaggio);
exit;
}
if($password=="")
{
$messaggio=urlencode("Non hai inserito la password");
header('location:'.'accept.php'.'?msg='.$messaggio);
exit;
}
//$password = md5($pwd);
$query="select * from plimun where user='$username' AND pwd='$password'";
$result=mysql_query($query)or die(mysql_error());
if($dati=mysql_fetch_array($result,MYSQL_ASSOC))
{
$_SESSION['valid_user']=isset($_POST['username']);
$_SESSION['valid_pass']=isset($_POST['password']);
$_SESSION['valid_time']=time();
header('location:'.'../menu.php');
}
else
{
$messaggio=urlencode("Username e/o Password errata");
header('location:'.'accept.php'.'?msg='.$messaggio);
exit;
}
}
infine ho una pagina chiamata menu.php che mi farà comparire il pannello di amministrazione del sito.
Menu.php
PHP:
<?php
if(isset($_SESSION['username']))
{
$messaggio=urlencode("Ti consiglio di autenticarti");
header('location:'.'watch/accept.php'.'?msg='.$messaggio);
exit;
}
?>
<html>
<head>
<meta http-equiv="Content-Language" content="it">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Pannello di controllo Area principale</title>
</head>
<body>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="605" height="79" id="AutoNumber1">
<tr>
<td width="34" height="79" rowspan="3">
<img border="0" src="immages/active_curva_sx.gif" width="33" height="93"></td>
<td width="270" height="6" colspan="3">
<img border="0" src="immages/active_linea.gif" width="270" height="11"></td>
<td width="299" height="6" colspan="3">
<img border="0" src="immages/active_linea.gif" width="270" height="11"></td>
<td width="99" height="36" rowspan="3">
<img border="0" src="immages/active_curva_dx.gif" width="33" height="94"></td>
</tr>
<tr>
<td width="76" height="65" valign="top" bgcolor="#FFFFFF">
<a href="app_scelta_articolo.php">
<img border="0" src="immages/articolo.gif" width="90" height="68"></a></td>
<td width="76" height="65" valign="top" bgcolor="#FFFFFF">
<a href="app_scelta_categoria.php">
<img border="0" src="immages/categoria.gif" width="90" height="68"></a></td>
<td width="91" height="65" valign="top" bgcolor="#FFFFFF">
<a href="app_eye_contatto.php">
<img border="0" src="immages/contatto.gif" width="90" height="68"></a></td>
<td width="9" height="65" valign="top" bgcolor="#FFFFFF">
<a href="app_eye_ordine.php">
<img border="0" src="immages/ordine.gif" width="90" height="68"></a></td>
<td width="22" height="65" valign="top" bgcolor="#FFFFFF">
<img border="0" src="immages/newsletter.gif" width="90" height="68"></td>
<td width="107" height="65" valign="top" bgcolor="#FFFFFF">
<img border="0" src="immages/banner.gif" width="90" height="68"></td>
</tr>
<tr>
<td width="270" height="7" colspan="3"> <img border="0" src="immages/active_linea.gif" width="270" height="11"></td>
<td width="299" height="7" colspan="3">
<img border="0" src="immages/active_linea.gif" width="270" height="11"></td>
</tr>
</table>
</div>
</body>
</html>
Adesso vi posto i 2 problemi principali
* Mi dareste una guardatina alla pagina login.php per vedere la parte delle sessioni se c'è un errore?
* Dopo aver inserito i dati giusti in accept.php mi dovrebbe apparire menu.php, però se tento di andare direttamente alla pagina menu.php senza aver fatto il login vorrei che mi desse un messaggio di errore, come potete notare in menu.php c'è qualcosa ma ho notato che serve a poco.
spero di essere stato almeno chiaro
ciao a tutti