<form="form1" method="post" action="<?php $_SERVER['PHP_SELF'] ?>"> form name="form1" method="post" action="<?php $_SERVER['PHP_SELF'] ?>"> <tr><td align="right" width="34"> Nom
</td> <td><input name="nom" type="text" class="textearea" id="nom" size="15"></td> <td align="right"> Prénom
</td> <td><input name="prénom" type="text" class="textearea" id="prénom" size="15"><input class="input" type="submit" name="submit" value="Ok"> <span class="separ"> *Saisir la 1ère lettre du nom et prénom en majuscule ex : Bruce Lee </span></td> </tr>
</form>
et mon traitement :
<?php
// Récupération des données du formulaire
if (isset($_POST['envoi']))
{
//connexion à la bdd
$connexion=mysql_connect("localhost","root","");
mysql_select_db("test",$connexion);
$nom=$_POST['nom'];
$prénom=$_POST['prénom'];
$requete="insert into liste values('','$prénom','$nom')";
mysql_query($requete);
}
?>
<?
//connexion à la bdd
$connexion=mysql_connect("localhost","root","");
mysql_select_db("test",$connexion);
//créer la requete et insertion
//requete et affiche
$requete="select id,nom,prénom from liste order by nom";
$envoi=mysql_query($requete);
// début de la boucle
while($tableau = mysql_fetch_array($envoi)) {
// on stocke nos données
$tablo[]=$tableau;
}
$nbcol=4; // nombre de colonnes
echo '<table bgcolor=#FFFFFF cellspacing=0 cellpadding=0 align=center border=1 bordercolor=#afc5cc rules=none>';
for($i=0;$i<count($tablo);$i++){
if($i%$nbcol==0)
echo '<tr>';
echo '<td class=bordureDroite>'.$tablo[$i]['id'].'</td><td class=bordureDroite>'.$tablo[$i]['prénom'].'</td><td class=bordureDroite>'.$tablo[$i]['nom'].'</td>';
if($i%$nbcol==($nbcol-1) or $i==(count($tablo)-1))
echo '</tr>';
}
echo '</table>';
//fermeture de la connexion vers MySQL
mysql_close();
?>
voilà , ca m'affiche pas d'erreur quand je veux insérer un nom ,l'insertion ne se fait pas(juste un bla<form id="form1" method="post" action="<?php $_SERVER['PHP_SELF'] ?>">
<table summary="">
<tr>
<td align="right" width="34"> Nom </td>
<td><input name="nom" type="text" class="textearea" id="nom" size="15"></td>
<td align="right"> Prénom </td>
<td><input name="prenom" type="text" class="textearea" id="prenom" size="15"><input class="input" type="submit" name="submit" value="Ok"> <span class="separ"> *Saisir la 1ère lettre du nom et prénom en majuscule ex : Bruce Lee </span></td>
</tr>
</table>
</form>
Et ton traitement :
<?php
// Récupération des données du formulaire
if (isset($_POST['envoi']))
{
//connexion à la bdd
$connexion=mysql_connect("localhost","root","");
mysql_select_db("test",$connexion);
$nom=$_POST['nom'];
$prénom=$_POST['prenom'];
$requete="insert into liste values('','". $prenom ."','". $nom ."')";
mysql_query($requete);
}
//connexion à la bdd
$connexion=mysql_connect("localhost","root","");
mysql_select_db("test",$connexion);
//créer la requete et insertion
//requete et affiche
$requete="select id,nom,prenom from liste order by nom";
$envoi=mysql_query($requete);
// début de la boucle
while($tableau = mysql_fetch_array($envoi))
{
// on stocke nos données
$tablo[]=$tableau;
}
$nbcol=4; // nombre de colonnes
?>
<table bgcolor=#FFFFFF cellspacing=0 cellpadding=0 align=center border=1 bordercolor=#afc5cc rules=none>
<?php
for($i=0;$i<count($tablo);$i++)
{
if($i%$nbcol==0)
{
?>
<tr>
<?php
}
?>
<td class=bordureDroite><?php echo($tablo[$i]['id']); ?></td>
<td class=bordureDroite><?php echo($tablo[$i]['prenom']); ?></td>
<td class=bordureDroite><?php echo($tablo[$i]['nom']); ?></td>
<?php
if($i%$nbcol==($nbcol-1) or $i==(count($tablo)-1))
{
?>
</tr>
<?php
}
}
?>
</table>
<?php
//fermeture de la connexion vers MySQL
mysql_close();
?><html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
table {font-size:10px
}
body {
background-color:#f6ffff
}
a.function:active {
color: #ff9933;
}
a.function {
color: #ff9933;
}
a.function:link {
}
a.function:visited {
color: #ff9933;
}
a.function:hover {
color: #ff9933;
text-decoration:none
}
</style>
<script language="JavaScript" type="text/javascript">
<!-- Hide script from old browsers
function newWindow() {
catWindow = window.open("noticelist.htm", "catWin", "width=650,height=800")
}
// End hiding script from old browsers -->
<!--
function show2() {
if(document.getElementById)
document.getElementById ("form1").style.visibility = "visible";
}
function show3() {
if(document.getElementById)
document.getElementById ("form2").style.visibility = "visible";
}
//-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body leftmargin="0" topmargin="10" marginwidth="0" marginheight="0" bgcolor="#f6ffff">
<?php
// Récupération des données du formulaire
if (isset($_POST['envoi']))
{
//connexion à la bdd
$connexion=mysql_connect("localhost","root","");
mysql_select_db("test",$connexion);
$nom=$_POST['nom'];
$prénom=$_POST['prenom'];
$requete="insert into liste values('','". $prenom ."','". $nom ."')";
mysql_query($requete);
}
?>
<table width="911" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td valign="top" bgcolor="dodce0" width="205"><a href="backoffice.php"><img src="1wingmyadmin.gif" border="0"></a></td>
<td>
<table width="800" border="0" cellpadding="0" cellspacing="0" bgcolor="f6ffff" align="center">
<tr>
<td valign="top" align="left">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="500" align="center">
<a href="javascript:show2()" class="function">Ajouter un invité</a> |
<a href="javascript:show3()" class="function">Effacer un invité</a> |
<a href="mdp.php" class="function">Voir la modification sur le site</a>
<a href="javascript:newWindow()" class="menu01">notice</a>
</td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" align="left" id="form1" style="visibility:hidden">
<form id="form1" method="post" action="<?php $_SERVER['PHP_SELF'] ?>">
<tr>
<td align="right" width="34"> Nom </td>
<td><input name="nom" type="text" class="textearea" id="nom" size="15"></td>
<td align="right"> Prénom </td>
<td><input name="prenom" type="text" class="textearea" id="prenom" size="15"><input class="input" type="submit" name="submit" value="Ok"> <span class="separ"> *Saisir la 1ère lettre du nom et prénom en majuscule ex : Bruce Lee </span></td>
</tr> </form>
</table>
</td>
</tr>
</table>
<tr><td valign="top">
<table border="0" cellspacing="0" cellpadding="0" align="left" id="form2" style="visibility:hidden">
<form name="form2" method="post" action="suppr.php">
<tr>
<td width="34" align="right"> Id </td>
<td><input name="id" type="text" class="textearea" id="id" size="3" maxlength="3">
<input type="image" src="suppr.gif" alt="suppression" name="submit2" value="Suppression">
<span class="separ"> *Saisir le n° de l'identité dans la liste à effacer</span></td>
</tr>
</form>
</table>
</td>
</tr>
</table>
<table bgcolor="#f6ffff" width="100%" align="center">
<tr><td>
<?php
//connexion à la bdd
$connexion=mysql_connect("localhost","root","");
mysql_select_db("test",$connexion);
//créer la requete et insertion
//requete et affiche
$requete="select id,nom,prenom from liste order by nom";
$envoi=mysql_query($requete);
// début de la boucle
while($tableau = mysql_fetch_array($envoi))
{
// on stocke nos données
$tablo[]=$tableau;
}
$nbcol=4; // nombre de colonnes
?>
<table bgcolor=#FFFFFF cellspacing=0 cellpadding=0 align=center border=1 bordercolor=#afc5cc rules=none>
<?php
for($i=0;$i<count($tablo);$i++)
{
if($i%$nbcol==0)
{
?>
<tr>
<?php
}
?>
<td class=bordureDroite><?php echo($tablo[$i]['id']); ?></td>
<td class=bordureDroite><?php echo($tablo[$i]['prenom']); ?></td>
<td class=bordureDroite><?php echo($tablo[$i]['nom']); ?></td>
<?php
if($i%$nbcol==($nbcol-1) or $i==(count($tablo)-1))
{
?>
</tr>
<?php
}
}
?>
</table>
<?php
//fermeture de la connexion vers MySQL
mysql_close();
?>
</td></tr>
</table></td>
</tr>
</table>
</body>
</html>
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
table {font-size:10px
}
body {
background-color:#f6ffff
}
a.function:active {
color: #ff9933;
}
a.function {
color: #ff9933;
}
a.function:link {
}
a.function:visited {
color: #ff9933;
}
a.function:hover {
color: #ff9933;
text-decoration:none
}
</style>
<script language="JavaScript" type="text/javascript">
<!-- Hide script from old browsers
function newWindow() {
catWindow = window.open("noticelist.htm", "catWin", "width=650,height=800")
}
// End hiding script from old browsers -->
<!--
function show2() {
if(document.getElementById)
document.getElementById ("form1").style.visibility = "visible";
}
function show3() {
if(document.getElementById)
document.getElementById ("form2").style.visibility = "visible";
}
//-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body leftmargin="0" topmargin="10" marginwidth="0" marginheight="0" bgcolor="#f6ffff">
<?php
// Récupération des données du formulaire
if (isset($_POST['envoi']))
{
//connexion à la bdd
$connexion=mysql_connect("localhost","root","");
mysql_select_db("test",$connexion);
$nom=$_POST['nom'];
$prénom=$_POST['prenom'];
$requete="insert into liste values('','". $prenom ."','". $nom ."')";
/* ~~~~~~~~~~~ débuggage ~~~~~~~~~~ */
echo($requete);
mysql_query($requete);
}
?>
<table width="911" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td valign="top" bgcolor="dodce0" width="205"><a href="backoffice.php"><img src="1wingmyadmin.gif" border="0"></a></td>
<td>
<table width="800" border="0" cellpadding="0" cellspacing="0" bgcolor="f6ffff" align="center">
<tr>
<td valign="top" align="left">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="500" align="center">
<a href="javascript:show2()" class="function">Ajouter un invité</a> |
<a href="javascript:show3()" class="function">Effacer un invité</a> |
<a href="mdp.php" class="function">Voir la modification sur le site</a>
<a href="javascript:newWindow()" class="menu01">notice</a>
</td>
</tr>
</table>
<form id="form1" method="post" action="<?php echo($_SERVER['PHP_SELF']); ?>">
<table border="0" cellspacing="0" cellpadding="0" align="left" id="form1" style="visibility:hidden">
<tr>
<td align="right" width="34"> Nom </td>
<td><input name="nom" type="text" class="textearea" id="nom" size="15"></td>
<td align="right"> Prénom </td>
<td><input name="prenom" type="text" class="textearea" id="prenom" size="15"><input class="input" type="submit" name="submit" value="Ok"> <span class="separ"> *Saisir la 1ère lettre du nom et prénom en majuscule ex : Bruce Lee </span></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<tr>
<td valign="top">
<table border="0" cellspacing="0" cellpadding="0" align="left" id="form2" style="visibility:hidden">
<form name="form2" method="post" action="suppr.php">
<tr>
<td width="34" align="right"> Id </td>
<td>
<input name="id" type="text" class="textearea" id="id" size="3" maxlength="3">
<input type="image" src="suppr.gif" alt="suppression" name="submit2" value="Suppression">
<span class="separ"> *Saisir le n° de l'identité dans la liste à effacer</span>
</td>
</tr>
</form>
</table>
</td>
</tr>
</table>
<table bgcolor="#f6ffff" width="100%" align="center">
<tr>
<td>
<?php
//connexion à la bdd
$connexion=mysql_connect("localhost","root","");
mysql_select_db("test",$connexion);
//créer la requete et insertion
//requete et affiche
$requete="select id,nom,prenom from liste order by nom";
$envoi=mysql_query($requete);
// début de la boucle
$tablo = array();
while($tableau = mysql_fetch_array($envoi))
{
// on stocke nos données
$tablo[]=$tableau;
}
$nbcol=4; // nombre de colonnes
?>
<table bgcolor=#FFFFFF cellspacing=0 cellpadding=0 align=center border=1 bordercolor=#afc5cc rules=none>
<?php
for($i=0;$i<count($tablo);$i++)
{
if($i%$nbcol==0)
{
?>
<tr>
<?php
}
?>
<td class=bordureDroite><?php echo($tablo[$i]['id']); ?></td>
<td class=bordureDroite><?php echo($tablo[$i]['prenom']); ?></td>
<td class=bordureDroite><?php echo($tablo[$i]['nom']); ?></td>
<?php
if($i%$nbcol==($nbcol-1) or $i==(count($tablo)-1))
{
?>
</tr>
<?php
}
}
?>
</table>
<?php
//fermeture de la connexion vers MySQL
mysql_close();
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>if (isset($_POST['submit']))
et non pas $_POST['envoi'] $requete="insert into liste values('','". $prenom ."','". $nom ."')";
???<?php
// Récupération des données du formulaire
if (isset($_POST['submit']))
{
//connexion à la bdd
$connexion=mysql_connect("localhost","root","");
mysql_select_db("test",$connexion);
$nom=$_POST['nom'];
$prénom=$_POST['prenom'];
$requete="insert into liste values('','". $prenom ."','". $nom ."')";
/* ~~~~~~~~~~~ débuggage ~~~~~~~~~~ */
echo($requete);
mysql_query($requete);
}
?>
Non là je vois pas, il affiche la valeur de nom mais pas celle de prenom.