Ciao a tutti ho un problema con il login dell' area riservata che ho creato in un sito e-commerce dove l'amministratore potrà inserire i prodotti o eliminarli quando inserisco username e password non vengono riconosciuti e mi rimanda alla pagina di login ho ricontrollato i codici molte volte anche nel Dreamweaver non trovo nessun errore di sintassi potreste aiutarmi a capire cosa non va?
I codici sono i seguenti nella pagina di login :
Codice PHP:
<?PHP
session_start();
if(isset($_SESSION["manager"])){
header("location:index.php");
exit();
}
?>
<?php
//Parse the log in form if user has filled out and pressed "Log In"
if(isset($_POST["username"])&&isset($_POST["password"])){
$manager=preg_replace('#[^A_Za-z0-9]#i',"",$_SESSION["manager"]);//filter everything but number and letters
$password=preg_replace('#[^A_Za-z0-9]#i',"",$_SESSION["password"]);//filter everything but number and letters
//Connect to the mySQL database
include"../storescripts/connect_to_mysql";
$sql=mysql_query("SELECT id FROM admin WHERE username='$username' AND password='$password' LIMIT 1");//query the person
//------MAKE SURE PERSONE EXIST IN DATABASE------
$existCount=mysql_num_rows($sql);//count the row nums
if($existCount==1){//evaluate the count
while($row=mysql_fetch_array($sql)){
$id=$row["id"];
}
$_SESSION["id"]=$id;
$_SESSION["manager"]=$manager;
$_SESSION["password"]=$password;
header("location:index.php");
exit();
}else{
echo'Usenrame o password errati<a href="index.php">Clicca Qui</a>';
exit();
}
}
?>
Codice index :
Codice PHP:
<?PHP
session_start();
if(!isset($_SESSION["manager"])){
header("location:admin_login.php");
exit();
}
//Be sure to check that this manager SESSION value is in fact in the database
$managerID=preg_replace('#[^0_9]#i',"",$_SESSION["id"]);//filter everything but number and letters
$manager=preg_replace('#[^A_Za-z0-9]#i',"",$_SESSION["manager"]);//filter everything but number and letters
$password=preg_replace('#[^A_Za-z0-9]#i',"",$_SESSION["password"]);//filter everything but number and letters
//Run mySQL query to be sure that this person is an admin and that their password session var equals the database
//Connect to the MySQL database
include"../storescripts/connect_to_mysql";
$sql=mysql_quesry("SELECT*FROM admin WHERE id='$managerID' AND username='$username' AND password='$password' LIMIT 1");//query the person
//------MAKE SURE PERSON EXIST IN DATABASE-----
$existCount=mysql_num_rows($sql);//count the row nums
if($existCount==0){//evaluate the count
header("location:../index.php");
exit();
}
?>
Sto' impazzendo da giorni per cercare di risolvere grazie