bonjour,

je code en ce moment le livre d'or d'un site pour le bac.
J'aimerais que dans ma table message (pour le livre d'or donc) il y est un champ (clef étrangère) pour récupérer l'id du membre de la table (membres) qui a posté le message. Or, je ne sais pas comment faire pour créer des clefs étrangères sous phpmyadmin ni comment lier les tables

voici le code du livre d'or :

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
 
 
<?php
session_start(); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
       <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	   <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <link rel="stylesheet" href="livreor.css" /> 
  <title> Livre d'Or </title>
  </head>
  <body>
 
 
  <?php include("en_tete.html"); ?>
  <?php include("menu.html"); ?>
  <?php include("connect.php"); ?>
  <?php include("connect_bdd.php");?>
 
 
	<h1> Livre d'Or </h1> <br/>
	<div id="central">
 
	<div class="connectlivreor">
	<table>
	<form method="post" action="livreor.php">
	<tr>
	<td><label for="idlivreor"> <span class="idformlivreor"> Identifiant </span></label> </td> <td> <input type="text" name="idlivreor" id="identifiant"/> </td>
	</tr>
	<tr>
	<td><label for="titrelivreor"> <span class="idformlivreor"> Titre </span></label> </td> <td> <input type="text" name="titrelivreor" id="titrelivreor"/> </td>
	</tr>
	<tr>
	<td><label for="msglivreor"> <span class="idformlivreor"> Message </span></label> </td> <td> <textarea type="text" name="msglivreor" id="msglivreor" rows="8" cols="70"> </textarea><br/>
			<input style="margin-top:13px; margin-left: 485px" type="submit" value="Envoyer"/></td>
	</tr>
 
	</form>
	</table>
 
 
	</div>
	<?php
	$mbr = "SELECT * FROM membres";
	$exe = mysql_query($mbr) or die ('erreur : '.mysql_error());
	$ligne = mysql_fetch_array($exe);
	$idbdd = $ligne['pseudo'];
			if(isset($_POST['idlivreor']) AND $idbdd == $_POST['idlivreor']) {
				$idlivreor = $_POST['idlivreor'];
				$titrelivreor = $_POST['titrelivreor'];
				$msglivreor = $_POST['msglivreor'];
 
				$ajout_msg = "INSERT INTO message(titre, contenu, id_membre_msg) VALUES ('$titrelivreor', '$msglivreor', '$idlivreor')";
				$ss = mysql_query($ajout_msg) or die ('erreur : '.mysql_error());
 
			}
?>
 
		<table border="2px">
		<tr> 
		<td style="width: 100px;" class="colaffichmsg"> 
		<?php 
			?> 
 
		</td>
		<td style="width: 300px;" class="colaffichmsg"> 
		message 
		</td>
		</tr>
		</table>
 
 
	</div>
 
  <?php include("pied_de_page.html"); ?>
 
    </body>
</html>
merci