ca c'est le code de mon formulaire :
<html>
<head>
<title>Ma premiere connexion à une BDD en php:</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 250px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
<script>
function Controle()
{
if (document.getElementById('login').value == '')
{
alert('Veuillez saisir un login.');
return false;
}
else if (document.getElementById('password').value == '')
{
alert('Veuillez saisir un password.');
return false;
}
return true;
}
</script>
<head>
<body>
<form action="BDD1.php" method="post" onSubmit="javascript:return Controle();">
<div align="center">
<table width="250" border="1" bordercolor="#000000">
<tr>
<td><table width="250" border="0">
<tr>
<td colspan="2"><div align="center">créer un enregistrement: </div></td>
</tr>
<tr>
<td>login:</td>
<td><input type="text" name="login" id="login"></td>
</tr>
<tr>
<td>password:</td>
<td><input tupe="text" name="password" id="password"></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="submit" value="Enregistrer">
</div></td>
</tr>
</table></td>
</tr>
</table>
</div>
</form>
<form method="post" action="PHP1.php">
<div align="center">
<input type="submit" value="Visualiser les enregistrements">
</div>
</form>
</body>
</html>
ca c'est mon script php qui permet d'ajouter des enregistrements :
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Ma premiere connexion à une BDD en php:</title>
</head>
<body>
<?php
//ecrire BDD
$connect = mysql_connect('******','*******','******') or die ("erreur de connexion");
mysql_select_db('clement',$connect) or die ("erreur de connexion base");
mysql_query("INSERT INTO login_password VALUES ('','$login','$password') ");
//lire BDD
mysql_select_db('clement',$connect) or die ("erreur de connexion base");
$result = mysql_query("SELECT numero,login,password from login_password");
while ( $row = mysql_fetch_array($result)){
echo $row[numero].' - '.$row[login].' - '.$row[password].'<br>';
}
mysql_close();
?>
<br>
[<a href="http://clement.antologic.com/php/BDD2.htm">retour</a>]
</body>
</html>
et ca c'est mon code pour visualiser les enregistrements:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>tout en php</title>
</head>
<body>
<?
$connect = mysql_connect('*******','***********','********') or die ("erreur de connexion");
mysql_select_db('clement',$connect) or die ("erreur de connexion base");
$result = mysql_query("SELECT numero,login,password from login_password");
while ( $row = mysql_fetch_array($result)){
echo $row[numero].' - '.$row[login].' - '.$row[password].'<br>';
}
mysql_close();
?>
<br>
[<a href="http://clement.antologic.com/php/BDD2.htm">retour</a>]
</body>
</html>