IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

problème d'identification sur un espace membre


Sujet :

PHP & Base de données

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Août 2008
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2008
    Messages : 8
    Points : 4
    Points
    4
    Par défaut problème d'identification sur un espace membre
    bonjour,

    J'ai essayé de faire un script php d'espace membre :
    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
    <?php require_once('Connections/client.php'); ?>
    <?php
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
    }
     
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }
     
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "login")) {
      $insertSQL = sprintf("INSERT INTO shop_client (mail, mdp) VALUES (%s, %s)",
                           GetSQLValueString($_POST['mail'], "text"),
                           GetSQLValueString($_POST['mdp'], "text"));
     
      mysql_select_db($database_client, $client);
      $Result1 = mysql_query($insertSQL, $client) or die(mysql_error());
     
      $insertGoTo = "ok.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }
     
    mysql_select_db($database_client, $client);
    $query_client = "SELECT * FROM shop_client";
    $client = mysql_query($query_client, $client) or die(mysql_error());
    $row_client = mysql_fetch_assoc($client);
    $totalRows_client = mysql_num_rows($client);
    ?><?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['mail'])) {
      $loginUsername=$_POST['mail'];
      $password=$_POST['mdp'];
      $MM_fldUserAuthorization = "";
      $MM_redirectLoginSuccess = "ok.php";
      $MM_redirectLoginFailed = "ko.php";
      $MM_redirecttoReferrer = false;
      mysql_select_db($database_client, $client);
        $LoginRS__query=sprintf("SELECT mail, mdp FROM shop_client WHERE mail='%s' AND mdp='%s'",
        get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
     
      $LoginRS = mysql_query($LoginRS__query, $client) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
         $loginStrGroup = "";
     
        //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 );
      }
    }
    ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Document sans titre</title>
    </head>
     
    <body>
    <form id="login" name="login" method="POST" action="<?php echo $loginFormAction; ?>">
      <p>Adresse mail :
        <input name="mail" type="text" id="mail" />
      </p>
      <p>
        <label>Mot de passe : 
        <input name="mdp" type="password" id="mdp" />
        </label>
    </p>
      <p>
        <label>
        <input type="submit" name="Submit" value="Se connecter" />
        </label>
      </p>
      <input type="hidden" name="MM_insert" value="login">
    </form>
    <p>&nbsp;</p>
     
    <p>&nbsp;</p>
    </body>
    </html>
    <?php
    mysql_free_result($client);
    ?>
    Quand j'essaie de le faire fonctionner, n'importe qui peut se connecter et cela remplit ma table shop_client avec un nom et un mot de passe et un id à chaque fois. Alors que je voulais qu'il compare le mail et le mot de passe à ma table shop_client mais pas rajouter de nouveaux clients.

    Pourriez-vous m'aider?

  2. #2
    Candidat au Club
    Profil pro
    Inscrit en
    Août 2008
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2008
    Messages : 8
    Points : 4
    Points
    4
    Par défaut probleme d'execution d'espace membre
    bon, j'ai changé mon script, le voici maintenant :
    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
    <?php require_once('Connections/client.php'); ?><?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['mail'])) {
      $loginUsername=$_POST['mail'];
      $password=$_POST['mdp'];
      $MM_fldUserAuthorization = "";
      $MM_redirectLoginSuccess = "ok.php";
      $MM_redirectLoginFailed = "ko.php";
      $MM_redirecttoReferrer = true;
      mysql_select_db($database_client, $client);
     
      $LoginRS__query=sprintf("SELECT mail, mdp FROM shop_client WHERE mail='%s' AND mdp='%s'",
        get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
     
      $LoginRS = mysql_query($LoginRS__query, $client) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
         $loginStrGroup = "";
     
        //declare two session variables and assign them
        $_SESSION['MM_Username'] = $loginUsername;
        $_SESSION['MM_UserGroup'] = $loginStrGroup;	      
     
        if (isset($_SESSION['PrevUrl']) && true) {
          $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
        }
        header("Location: " . $MM_redirectLoginSuccess );
      }
      else {
        header("Location: ". $MM_redirectLoginFailed );
      }
    }
    ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Document sans titre</title>
    </head>
     
    <body>
    <form id="login" name="login" method="POST" action="<?php echo $loginFormAction; ?>">
      <p>Adresse mail :
        <input name="mail" type="text" id="mail" />
      </p>
      <p>
        <label>Mot de passe : 
        <input name="mdp" type="password" id="mdp" />
        </label>
    </p>
      <p>
        <label>
        <input type="submit" name="Submit" value="Se connecter" />
        </label>
      </p>
     
    </form>
    <p>&nbsp;</p>
     
    <p>&nbsp;</p>
    </body>
    </html>
    et maintenant je suis sur la page ko à chaque fois même si mon adresse mail et mot de passe sont corrects
    Pouvez-vous m'aider? Merci

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Août 2008
    Messages
    28
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2008
    Messages : 28
    Points : 12
    Points
    12
    Par défaut
    tu utilise Dreamweaver ?

  4. #4
    Candidat au Club
    Profil pro
    Inscrit en
    Août 2008
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2008
    Messages : 8
    Points : 4
    Points
    4
    Par défaut problème d'identification sur un espace
    oui j'utilise dreamweaver8

  5. #5
    Membre à l'essai
    Profil pro
    Inscrit en
    Août 2008
    Messages
    28
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2008
    Messages : 28
    Points : 12
    Points
    12
    Par défaut
    apparemment tu as "fait connecter l'utilisateur" dans application-comportement de serveur, et pas "restreindre l'acc'es"

    Dw a des lourdeurs, mais ces fonctions là sont faciles à installer
    je te conseille de créer une page "accès" avec des balises pseudo/password et de faire restreindre l'accès sur ta page membre/client
    n'oublie pas d'y mettre également " déconnecter l'utilsateur"
    avec ça

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <?php echo "Bonjour ",    $_SESSION['MM_Username']; ?> !
    tu diras bonjour à ton utilisateur

  6. #6
    Candidat au Club
    Profil pro
    Inscrit en
    Août 2008
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2008
    Messages : 8
    Points : 4
    Points
    4
    Par défaut problème d'identification sur un espace membre
    j'ai utilisé dreamweaver8, je suis allée dans application-comportement serveur et là j'ai fait connecter utilisateur, malheureusement cela me dirige toujours vers la page qui ne me reconnaît pas (alors que dans le panneau de dreamweaver j'ai fait la distinction entre les 2 pages une ok et l'autre ko.
    Comme cela ne marchait pas j'ai fait restreindre la page et là j'ai le meme problème il rajoute les nouveaux utilisateurs dans ma base m^me si il ne les connaissait pas.
    Je voudrais que suivant le mail et le mot de passe, les utilsateurs mail et mot de passe correct aillent sur la page ok et les autres non reconnus sur la page ko

    Si tu pouvais m'aider cela serait sympa car j'y suis depuis longtemps....

  7. #7
    Membre à l'essai
    Profil pro
    Inscrit en
    Août 2008
    Messages
    28
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2008
    Messages : 28
    Points : 12
    Points
    12
    Par défaut
    bonjour
    1ere étape = formulaire d'enregistrement classique (insérer un enregistrement)
    2eme étape = formulaire d'accès ( connecter utilisateur)
    3eme étape = ta page membre > restreindre l'accès en définissant tes critères

    les étapes sont relativement facile à suivre avec DReamweaver. prends le temps
    de bien suivre les indications
    ce qui suit est du 100% Dw (chapca est une extension que tu peux télécharger gratos)
    ma partie php d'enregistrement :
    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
    <?php
    session_start();
    if(isset($_POST["chapca"])) {
    	if(($_SESSION['captcha_code'] == $_POST['chapca']) && (!empty($_SESSION['captcha_code'])) ) {
    		//Passed!
    		$captcha_msg="Thank you";
    	}else{
    		// Not passed 8-(
    		$captcha_msg="invalid code";
    		if(isset($_POST["MM_insert"])){
    	  		unset($_POST["MM_insert"]);
    		}
    		if(isset($_POST["MM_update"])){
    			unset($_POST["MM_update"]);
    		}
    	}
    }
    class CaptchaImage {
    	var $font = "verdana.ttf";
    	function hex_to_dec($hexcolor){
    	//convert hex hex values to decimal ones
    	$dec_color=array('r'=>hexdec(substr($hexcolor,0,2)),'g'=>hexdec(substr($hexcolor,2,2)),'b'=>hexdec(substr($hexcolor,4,2)));
    	return $dec_color;
    	}
    	function generateCode($characters) {
    		/* list all possible characters, similar looking characters and vowels have been removed */
    		$possible = '23456789bcdfghjkmnpqrstvwxyz'; 
    		$code = '';
    		$i = 0;
    		while ($i < $characters) { 
    			$code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
    			$i++;
    		}
    		return $code;
    	}
    	function CaptchaImage($width='120',$height='30',$characters='6',$hex_bg_color='FFFFFF',$hex_text_color="FF0000",$hex_noise_color="CC0000", $img_file='captcha.jpg') {
    		$rgb_bg_color=$this->hex_to_dec($hex_bg_color);
    		$rgb_text_color=$this->hex_to_dec($hex_text_color);
    		$rgb_noise_color=$this->hex_to_dec($hex_noise_color);
    		$code = $this->generateCode($characters);
    		/* font size will be 60% of the image height */
    		$font_size = $height * 0.60;
    		$image = @imagecreate($width, $height) or die('Cannot Initialize new GD image stream');
    		/* set the colours */
    		$background_color = imagecolorallocate($image, $rgb_bg_color['r'], $rgb_bg_color['g'],$rgb_bg_color['b']);
    		$text_color = imagecolorallocate($image, $rgb_text_color['r'], $rgb_text_color['g'],$rgb_text_color['b']);
    		$noise_color = imagecolorallocate($image, $rgb_noise_color['r'], $rgb_noise_color['g'],$rgb_noise_color['b']);
    		/* generate random dots in background */
    		for( $i=0; $i<($width*$height)/3; $i++ ) {
    			imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
    		}
    		/* generate random lines in background */
    		for( $i=0; $i<($width*$height)/150; $i++ ) {
    			imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
    		}
    		/* create textbox and add text */
    		$textbox = imagettfbbox($font_size, 0, $this->font, $code);
    		$x = ($width - $textbox[4])/2;
    		$y = ($height - $textbox[5])/2;
    		imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code);
    		/* save the image */
    		imagejpeg($image,$img_file);
    		imagedestroy($image);
    		echo "<img src=\"$img_file?".time()."\" width=\"$width\" height=\"$height\" alt=\"security code\" id=\"captchaImg\">";
    		$_SESSION['captcha_code'] = $code;
    	}
     
    }
    ?>
    <?php require_once('../Connections/mb.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;
    }
    }
    // *** 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['pseudo'])) {
      $loginUsername=$_POST['pseudo'];
      $password=$_POST['motpasse'];
      $MM_fldUserAuthorization = "";
      $MM_redirectLoginSuccess = "espace-membre.php";
      $MM_redirectLoginFailed = "acces-errone.php";
      $MM_redirecttoReferrer = false;
      mysql_select_db($database_mb, $mb);
     
      $LoginRS__query=sprintf("SELECT username, password FROM site_user WHERE username=%s AND password=%s",
        GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
     
      $LoginRS = mysql_query($LoginRS__query, $mb) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
         $loginStrGroup = "";
     
        //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
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }
    ?>
    <?php
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "membre")) {
      $insertSQL = sprintf("INSERT INTO site_user (prenom1, prenom2, nom1, nom2, email, password, username, sexe, jour, mois, annee, rue, numrue, ville, cp, province, pays, telephone) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['prenom1mem'], "text"),
                           GetSQLValueString($_POST['prenom2mem'], "text"),
                           GetSQLValueString($_POST['nom1mem'], "text"),
                           GetSQLValueString($_POST['nom2mem'], "text"),
                           GetSQLValueString($_POST['mailmembre'], "text"),
                           GetSQLValueString($_POST['password'], "text"),
                           GetSQLValueString($_POST['username'], "text"),
                           GetSQLValueString($_POST['sexe'], "text"),
                           GetSQLValueString($_POST['jourmem'], "text"),
                           GetSQLValueString($_POST['moismem'], "text"),
                           GetSQLValueString($_POST['anneemem'], "text"),
                           GetSQLValueString($_POST['rue'], "text"),
                           GetSQLValueString($_POST['numrue'], "text"),
                           GetSQLValueString($_POST['ville'], "text"),
                           GetSQLValueString($_POST['cp'], "text"),
                           GetSQLValueString($_POST['province'], "text"),
                           GetSQLValueString($_POST['pays'], "text"),
                           GetSQLValueString($_POST['telephone'], "text"));
     
      mysql_select_db($database_mb, $mb);
      $Result1 = mysql_query($insertSQL, $mb) or die(mysql_error());
     
      $insertGoTo = "paiement-abonnement.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }
     
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "membre")) {
      $insertSQL = sprintf("INSERT INTO site_session (sid, prenom) VALUES (%s, %s)",
                           GetSQLValueString($_POST['username'], "text"),
                           GetSQLValueString($_POST['prenom1mem'], "text"));
     
      mysql_select_db($database_mb, $mb);
      $Result1 = mysql_query($insertSQL, $mb) or die(mysql_error());
     
      $insertGoTo = "paiement-abonnement.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }
    ?>
    mon formulaire connecter
    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
    <?php require_once('../Connections/mb.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['pseudo'])) {
      $loginUsername=$_POST['pseudo'];
      $password=$_POST['motpasse'];
      $MM_fldUserAuthorization = "";
      $MM_redirectLoginSuccess = "espace-membre.php";
      $MM_redirectLoginFailed = "acces-errone.php";
      $MM_redirecttoReferrer = false;
      mysql_select_db($database_mb, $mb);
     
      $LoginRS__query=sprintf("SELECT username, password FROM site_user WHERE username=%s AND password=%s",
        GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
     
      $LoginRS = mysql_query($LoginRS__query, $mb) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
         $loginStrGroup = "";
     
        //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 );
      }
    }
    ?>
    espace membre
    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
    <?php
    //initialize the session
    if (!isset($_SESSION)) {
      session_start();
    }
     
    // ** Logout the current user. **
    $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
    if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
      $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
    }
     
    if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
      //to fully log out a visitor we need to clear the session varialbles
      $_SESSION['MM_Username'] = NULL;
      $_SESSION['MM_UserGroup'] = NULL;
      $_SESSION['PrevUrl'] = NULL;
      unset($_SESSION['MM_Username']);
      unset($_SESSION['MM_UserGroup']);
      unset($_SESSION['PrevUrl']);
     
      $logoutGoTo = "accueil.php";
      if ($logoutGoTo) {
        header("Location: $logoutGoTo");
        exit;
      }
    }
    ?>
    <?php
    if (!isset($_SESSION)) {
      session_start();
    }
    $MM_authorizedUsers = "";
    $MM_donotCheckaccess = "true";
     
    // *** Restrict Access To Page: Grant or deny access to this page
    function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
      // For security, start by assuming the visitor is NOT authorized. 
      $isValid = False; 
     
      // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
      // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
      if (!empty($UserName)) { 
        // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
        // Parse the strings into arrays. 
        $arrUsers = Explode(",", $strUsers); 
        $arrGroups = Explode(",", $strGroups); 
        if (in_array($UserName, $arrUsers)) { 
          $isValid = true; 
        } 
        // Or, you may restrict access to only certain users based on their username. 
        if (in_array($UserGroup, $arrGroups)) { 
          $isValid = true; 
        } 
        if (($strUsers == "") && true) { 
          $isValid = true; 
        } 
      } 
      return $isValid; 
    }
     
    $MM_restrictGoTo = "acces-errone.php";
    if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
      $MM_qsChar = "?";
      $MM_referrer = $_SERVER['PHP_SELF'];
      if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
      if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
      $MM_referrer .= "?" . $QUERY_STRING;
      $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
      header("Location: ". $MM_restrictGoTo); 
      exit;
    }
    ?>
    je ne peux pas te dire plus que ça, ça marche très bien

Discussions similaires

  1. session qui se melange sur un espace membre
    Par monlou dans le forum Langage
    Réponses: 7
    Dernier message: 12/08/2014, 22h43
  2. Espace Membres Problème dans l'identification
    Par SickPerson dans le forum PHP & Base de données
    Réponses: 20
    Dernier message: 17/04/2013, 00h58
  3. [FF] Problème d'identification sur un site
    Par ghizou771 dans le forum Firefox
    Réponses: 2
    Dernier message: 22/04/2008, 22h15
  4. [Tableaux] problème avec espace membre
    Par ph_anrys dans le forum Langage
    Réponses: 10
    Dernier message: 01/03/2006, 17h26
  5. Espace membre sur un serveur Free
    Par stilobique dans le forum Langage
    Réponses: 11
    Dernier message: 16/02/2006, 11h51

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo