Niente da fare non funziona. Forse ho sbagliato in qualche altra pagina, te le passo.
index.html:
Codice PHP:
<!DOCTYPE html>
<html>
<head><title>Home</title>
</head>
<body>
<form action="main_login.php"><input type="submit" value="Login"><br></form>
<form action="Registrazione.php"><input type="submit" value="Registrazione"></form>
</body>
</html>
login:
Codice PHP:
<HTML>
<HEAD>
<TITLE>Login</TITLE>
</HEAD>
<BODY>
<table border="0" cellspacing="1" cellpadding="0" width="300" align="center" bgcolor="#cccccc"><tbody>
<tr><form action="checklogin.php" method="post"> <input name="phpMyAdmin" type="hidden" value="V0N0db6Fl62QWr6eBkly75xAGn3" /><td>
<table border="0" cellspacing="1" cellpadding="3" width="100%" bgcolor="#ffffff"><tbody>
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input id="myusername" name="myusername" type="text" /></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input id="mypassword" name="mypassword" type="password" /></td>
</tr>
<tr>
<td></td>
<td></td>
<td><input name="Submit" type="submit" value="Login" /></td>
</tr>
</tbody></table>
</td>
</form></tr>
</tbody></table>
</BODY>
</HTML>
checklogin: (lascio la password vuota per motivi di sicurezza)
Codice PHP:
<?php
$host="localhost"; // Hostname
$username="howcraft"; // Mysql username
$password=""; // Mysql password
$db_name="my_howcraft"; //Nome del Database
$tbl_name="members"; // Nome della Tabella
// Procedimento per connettersi al Database
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Nome utente e password inviate attraverso il form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Attenzione username o password errati";
}
?>