ho questo codice che non mi dà nessun tipo di ERROR ma una volta compilati i campi (username&password) e schiacciato il button del login, mi ritorna nella pagina stessa con i campi vuoti senza darmi nessun errore..le tabelle sql sono corrette...sto veramente impazzendo...PLEASE HELP ME
Codice PHP:
<?php
if(!isset($_SESSION)){
session_start ();
}
?>
<?php
if( isset($_POST['submit_x']) && (trim($_POST['submit_x'] == "invia")))
{
if((!isset($_POST['username'])) || ($_POST['username'] == ""))
{
echo "Attenzione, username non corretto!";
}
elseif((!isset($_POST['password'])) || ($_POST['password'] == "") || (!preg_match("/^[a-z0-9]+$/i", $_POST['password'])))
{
echo "Attenzione, password non corretta.";
}else{
$username = $_POST['username'];
$password = $_POST['password'];
include_once "connect.php";
$ctrl_login = mysql_query("SELECT id FROM iscrizioni WHERE username='$username' AND password='$password'") or die (mysql_error());
if(mysql_num_rows($ctrl_login)==0)
{
echo "Login incorretto.";
}else{
$obj = mysql_fetch_array($ctrl_login) or die (mysql_error());
($obj['id']);
$_SESSION['id'] = $obj['id'];
($_SESSION['id']);
header("Location: iscritti.php");
}
}
}else{
?>
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post">
<p align="center" style="margin-top: -20px; margin-bottom: 0">
[img]username.gif[/img]
<input name="username" type="text" size="20">
[img]password.gif[/img]
<input name="password" type="password" size="20"></p>
<p align="center" style="margin-top: -8px; margin-bottom: 0">
<input name="submit" type="image" src="buttonlogin.gif">
<a href="registrazione.php">
[img]buttonregister.gif[/img]</a></p>
<p align="center" style="margin-top: -8px; margin-bottom: 0"></p>
<p align="center" style="margin-top: -8px; margin-bottom: 0"><u>
<font size="1" color="#0000FF" face="Arial">[url="richiesta_password.php"]>>[/url]</font><a href="richiesta_password.php"><font face="Tahoma" size="1" color="#0000FF">
hai dimenticato la password?</font></a></u></p>
</form>
<?
}
?>
Qulcuno mi può aiutare?