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?