1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| <?php
//===============================================
//===============================================
//fichier login.php
session_start();
?>
<html>
<form name="form1" method="post" action="login.php">
<table>
<tr><td>Username </td><td><input type="text" name="text1"></td></tr>
<tr><td>Password</td><td><input type="password" name="pwd"></td></tr>
<tr><td><input type="submit" value="SignIn" name="submit1"> </td></tr>
</table>
</form>
</html>
<?php
if(isset ($_POST['submit1']))
{
$v1 = "aaa";
$v2 = "123";
$v3 = $_POST['text1'];
$v4 = $_POST['pwd'];
if(($v1 == $v3) && ($v2 == $v4))
{
// l'autentification normalement se faire avec une base de données
//********* enregister l'utilisateur connecté sur la nouvelle table ( connexion réussite
$date_now =date('Y-m-j H:i:s');
$insertuser="INSERT INTO connexions (user, date_connexion, derniere_action, online) VALUES ('$v3','$date_now','$date_now', '1')";
mysql_query($insertuser, $connexion) or die (mysql_error());
// recupérer id de l'authentification
$select_conn="SELECT id FROM connexions WHERE user='$v3' AND date_connexion='$date_now' AND derniere_action='$date_now' AND online='1'";
$result=mysql_query($select_conn, $connexion) or die (mysql_error());
$row_id=mysql_fetch_assoc ($result);
$id=$row_id['id'];
$_SESSION['id']=$id;
$_SESSION['luser'] = $v1;
$_SESSION['start'] = time(); // taking now logged in time
$_SESSION['expire'] = $_SESSION['start'] + (60) ; // ending a session in 10 seconds from the starting time
//header('Location:index.php');
header ("location:index.php");
}
else
{
echo "Please enter Username or Passwod again !";
}
}
?> |