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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
| <?
session_start();
session_register('login','password','statut');
?>
<html>
<body>
<?
$connectok=false;
if (isset($_POST['deconnecter']))
{
$_SESSION['login']='';
$_SESSION['password']='';
$_SESSION['statut']='';
}
if (isset($_POST['login']))
{
$_SESSION['login']=$_POST['login'];
$_SESSION['password']=$_POST['password'];
}
if ((isset($_SESSION{'login'})) & (isset($_SESSION{'password'})))
{
$dblink=mysql_connect('localhost','root','');
mysql_select_db('table',$dblink);
$req="SELECT * FROM table WHERE login='".$_SESSION{'login'}."'";
$dbresult=mysql_query($req,$dblink);
while($row=mysql_fetch_array($dbresult))
{
$connectok=($row['password']==sha1($_SESSION['password']));
}
}
else
{
$connectok=false;
}
?>
<table width = "100%" border = "1">
<tr>
<td height="100" colspan="2">
<?
echo "<img src=\"accueil2.gif\" width=\"100%\">";
?>
</td>
</tr>
<tr>
<td>
<?
include "menu.php";
?>
</td>
<td>
<?
if ($connectok)
{
echo "<form method =\"post\" action=\"index.php\">";
echo "<input type = \"submit\" name = \"deconnecter\" value=\"Se déconnecter\">";
echo "</form>";
include "contenu.php";
}
else
{
echo "<form method=\"post\" action=\"index.php\">";
echo "<fieldset>";
echo "<legend>" ;
echo "connexion";
echo "</legend>";
echo "<table>";
echo "<tr>";
echo "<td>";
echo "Login :";
echo "</td>";
echo "<td>";
echo "<input type=\"text\" name=\"login\" size=\"15\" maxlength=\"10\">";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo "Mot de passe :";
echo "</td>";
echo "<td>";
echo "<input type=\"password\" name=\"password\" size=\"15\" maxlength=\"10\">";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan=\"2\">";
echo "<input type=\"submit\" value=\"se connecter\">";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</fieldset>";
echo "</form>";
}
?>
</td>
</tr>
</body>
</html> |
Partager