bonjour à tous je un souci de fermeture de session je voudrais rajouter un bouton pour permettre aux membres une déconnexion avec redirection sur la page index.php

j'ai un bouton connexion mais pas déconnexion comment faire merci pour vos aides Lucas de Almeida Meesemaecker Adilson

voici une partie de mon code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<?php require_once('Connections/connexion.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}
 
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
 
if (isset($_POST['email'])) {
  $loginUsername=$_POST['email'];
  $password=$_POST['passe'];
  $MM_fldUserAuthorization = "statut";
  $MM_redirectLoginSuccess = "index.php";
  $MM_redirectLoginFailed = "erreurlogin.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_connexion, $connexion);
 
  $LoginRS__query=sprintf("SELECT email, passe, statut FROM an_membre WHERE email=%s AND passe=%s",
  GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
 
  $LoginRS = mysql_query($LoginRS__query, $connexion) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
 
    $loginStrGroup  = mysql_result($LoginRS,0,'statut');
 
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;	      
 
    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
<?php 
mysql_select_db($database_connexion, $connexion);
$query_Recordset1 = "SELECT mail FROM an_config";
$Recordset1 = mysql_query($query_Recordset1, $connexion) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
 
$colname_mail = "-1";
if (isset($_POST['mailperdu'])) {
  $colname_mail = (get_magic_quotes_gpc()) ? $_POST['mailperdu'] : addslashes($_POST['mailperdu']);
}
 
$query_mail = sprintf("SELECT * FROM an_membre WHERE email = '%s'", $colname_mail);
$mail = mysql_query($query_mail, $connexion) or die(mysql_error());
$row_mail = mysql_fetch_assoc($mail);
$totalRows_mail = mysql_num_rows($mail);
 
if(! isset($_POST['mailperdu'])){$_POST['mailperdu']="null";}
$mailperdu=$_POST['mailperdu'];
 
if(! isset($_GET['acti'])){$_GET['acti']="null";}
$acti=$_GET['acti'];
if($acti=='passeperdu')
{
$mailperdu=$_POST['mailperdu'];
if($row_Recordset1['mail']=="email")// si c fonction email(online)
  {
 $suj="Votre demande de mot de passe";
	 $msg="Vous avez fait une demande pour recevoir votre mot de passe<br>MOT DE PASSE :$passe"; 
        if(@!email("webmaster",$mailperdu, $suj, $msg));
		header("location:login.php"); 
   }
   if($row_Recordset1['mail']=="mail")// si c fonction email(online)
	{
	$from="webmaster@scripthp.com";
	$suj="Votre demande de mot de passe";
	 $msg="Vous avez fait une demande pour recevoir votre mot de passe<br>MOT DE PASSE :$passe";
	 @mail($mailperdu,$suj,$msg,$from);
	}
	 header("location:login.php");  
	}//---------------------fin du if acti=inscription
 
 
?>
<html>
<head>
<title>64-annuaire.fr</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="feuille.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
 
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' n est pas valide.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' est obligatoire.\n'; }
  } if (errors) alert('ATTENTION\n'+errors);
  document.MM_returnValue = (errors == '');
}
//-->
</script>
<style type="text/css">
<!--
.Style1 {color: #666666}
-->
</style>
</head>
 
<body>
<div align="center">
  <table width="100%"  border="0">
    <tr>
      <td><p>&nbsp;</p>
        <p><br>        
        </p>
        <hr width="60%" color="#E0DFE3">
        <div align="center"><span class="Style1 Style2 Style3 Style1"><br>
          </span><span class="sidebarHeader Style1">CONNEXION</span><br>
          <br>
          Tous les champs sont obligatoires <br>
          <br>
        </div>
        <div align="center">
          <table width="34%"  border="1">
            <tr>
              <td height="126"><div align="center">
                <form ACTION="<?php echo $loginFormAction; ?>" method="POST" name="form1">
                  <table align="center">
                    <tr valign="baseline">
                      <td nowrap align="right">Email:</td>
                      <td><input type="text" name="email" size="32"></td>
                    </tr>
                    <tr valign="baseline">
                      <td nowrap align="right">Passe:</td>
                      <td><input type="password" name="passe" value="" size="32"></td>
                    </tr>
                    <tr valign="baseline">
                      <td nowrap align="right">connexion</td>
                      <td><div align="center"><input type="submit" onClick="MM_validateForm('email','','RisEmail','passe','','R');return document.MM_returnValue" value="connexion"></td></div>
                    </tr>
                  </table>
                  <table width="100%"  border="0">
                    <tr>
                      <td><div align="center"><tt><a href="inscription.php">inscription</a></tt></div></td>
                     <? if ($row_Recordset1['mail']=="mail" || $row_Recordset1['mail']=="email")
                      {
					  print"<td><div align=\"center\"><a href=\"login.php?action=passe\">passe perdu </a></div></td>";
					  }
?> 
                    </tr>
                  </table>
                  <br>
                  <input type="hidden" name="statut" value="admin">
                </form>
                </div></td>
            </tr>
          </table>
 
 
          <?
		  if(! isset($_GET['action'])){$_GET['action']="null";}
		 $action=$_GET['action'];
		    if($action=='passe')
		  {
		  echo"<br>Pour avoir dans un mail votre mot de passe<br>
		  <table width=\"40%\"  border=\"0\">
    <tr>
      <td><div align=\"center\">Votre email d'inscription </div></td>
    </tr>
    <tr>
      <td><div align=\"center\">
        <form name=\"form2\" method=\"post\" action=\"passeperdu.php\">
          <input name=\"mailperdu\" type=\"text\" id=\"mailperdu\" value=\"\" size=\"35\">
          <br>
          <br>
          <input type=\"submit\" name=\"Submit\" value=\"Envoyer\">
                                        </form>
      </div></td>
    </tr>
  </table>";
		  }
		  ?>
		  <br>
      </div></td>
    </tr>
  </table>
  <br>
  <hr width="60%">
  <br>
</body>
</html>
<?php
mysql_free_result($Recordset1);
 
mysql_free_result($mail);
mysql_close($connexion);
 
?>