<?php
include ("config.php");
include ("miefunzioni.inc");
//verifica_SSL();
session_start();
if( !isset($_POST['utente']) and !isset($_POST['password']) )
{
?>
<html>
<head>
<title>Ricettario dello studente</title>
</head>
<body>
<font face="Arial" size="5" align="center">
Benvenuti nel "Ricettario dello studente"</font>
<font face="Arial" size="3" align="center">
Per poter usufruire dei servizi di questo sito bisogna essere iscritti.</font>
<form action="<?php print $_SERVER['PHP_SELF']; ?>" method="POST">
<th>Login: </th>
<input type="text" name="utente">
<th>Password: </th>
<input type="password" name="password">
<input type="submit" value ="Invia">
</form>
<font face ="arial">
Non sei ancora iscritto? ISCRIVITI!</font>
</body>
</html>
<?php
}
else
{
$ptr_mysqls=mysql_connect($dbhost,$dbusername,$dbp ass) //Connessione al database
or die("Impossibile connettersi al server MySQL.\n");
mysql_select_db($dbname, $ptr_mysqls)// selezione del database
or die("Impossibile aprire il database.\n");
$md5password=md5($_POST['password']); //generazione della password inserita nel database
$query_visualizzazione="SELECT * FROM '$tabutente'" .
" WHERE utente='{$_POST['utente']}' AND password='$md5password'";
$ptr_risultato_query=mysql_query($query_visualizza zione, $ptr_mysqls);
$numero_records=mysql_affected_rows($ptr_mysqls); // numero di righe di utenti in database
mysql_close($ptr_mysqls); // chiude il collegamento al database
if($numero_records == 1)
{
// Utente identificato
$_SESSION['utente']=$_POST['utente'];
$_SESSION['password']=$_POST['password'];
$_SESSION['IP_utente']=$_SERVER['REMOTE_ADDR'];
header("Location:
http://" . $_SERVER['HTTP_HOST'] .
dirname($_SERVER['PHP_SELF']) . "/ricettario.php");
exit;
}
?>
<html>
<head>
<title>Ricettario Studente</title>
</head>
<body>
<?php
$post = $_POST['utente'];
$pas = $_POST['password'];
var_dump($post);
var_dump($numero_records);
var_dump($md5password);
var_dump($ptr_risultato_query);
?>
<h3>Attenzione, Utente o Password non corretti!!!!
ripetere grazie</h3>
</body>
</html>
<?php
}
?>