e poi son passato a mysql perché è più comodo e mantiene più dati..
Ma come mai cosi funziona:
codice:
<?php
include_once("inc.php");
?>
<?php
if (isset($_POST['submit']))
{
if(empty($_POST["email"]))
{
$message = "Non inserito utente";
}elseif(empty($_POST["password"]))
{
$message= "Non inserito la password";
}else
{
$sql = "select COUNT(*) from users where email=:email and password=:password and pin=:pin LIMIT 1";
$stmt = $pdo->prepare($sql);
$stmt->execute(array(
'email' => $_POST["email"],
'password' => md5($_POST["password"]),
'pin'=>md5($_POST["pin"])));
if($stmt->fetchColumn() == 0)
{
$message = "No records found";
}
else{
$sql = "select * from users where email=:email and password=:password and pin=:pin LIMIT 1";
$stmt = $pdo->prepare($sql);
$stmt->execute(array(
'email' => $_POST["email"],
'password' => md5($_POST["password"]),
'pin'=>md5($_POST["pin"])));
session_start();
$rows = $stmt->fetchAll();
foreach($rows as $row)
{
$_SESSION['name']=$row["name"];
$_SESSION['login']=true;
$_SESSION['ruolo'] = $row["isAdmin"];
}
header("location: index.php");
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
</head>
<style>
.message {
color: #FF0000;
font-weight: bold;
text-align: center;
width: 100%;
}</style>
<body>
<form name="frmUser" method="post" action="login.php">
<div class="message"><?php if(isset($message)) { echo $message; } ?></div>
<table border="0" cellpadding="10" cellspacing="1">
<tr >
<td align="center" colspan="2">Login</td>
</tr>
<tr>
<td align="right">email</td>
<td><input type="text" name="email" size="50"></td>
</tr>
<tr >
<td align="right">Password</td>
<td><input type="password" name="password"></td>
</tr>
<tr >
<td align="right">Pin</td>
<td><input type="password" name="pin"></td>
</tr>
<tr >
<td align="center" colspan="2">
<input type="submit" name="submit" value="Submit"></td>
</tr>
</table>
</form>
mi protesti darmi una mano ?
hai guide anche in inglese ??
grazie mille.