<td width="20%" align="left"><input type="text" name="word" maxlength="30" size="20" value="<?php echo "$word"; ?>" class="input01"></td>
<td width="20%" align="left"><input type="text" name="word" maxlength="30" size="20" value="<?php echo "$replacement"; ?>" class="input01"></td>
J ai corrige et quand je lance l update ca me laisse les champs vides
SAlut, ce code est en dehors des balises <form> et </form><td width="20%" align="left"><input type="text" name="word" maxlength="30" size="20" value="<?php echo "$word"; ?>" class="input01"></td> <td width="20%" align="left"><input type="text" name="word" maxlength="30" size="20" value="<?php echo "$replacement"; ?>" class="input01"></td>
<a href="index.php?menu=GuestBookCensure&action=update&id=<?php echo($censure[id]); ?>" onClick="return conf();">Update</a>
tu ne peut donc pas récupèrer les variables POSTfunction conf()
{
if(confirm("Are you sure?"))
document.getElementById('form').submit();
}
<?php
$date = (isset($_POST['date'])) ? $_POST['date'] : "";
$hour = (isset($_POST['hour'])) ? $_POST['hour'] : "";
$word = (isset($_POST['word'])) ? $_POST['word'] : "";
$replacement = (isset($_POST['replacement'])) ? $_POST['replacement'] : "";
$action = (isset($_GET['action'])) ? $_GET['action'] : "";
$id = (isset($_GET['id'])) ? $_GET['id'] : "";
$host = 'localhost';
$user = 'root';
$pass = '';
$db_name = 'test';
$date = date("d/m/Y");
$hour = date("H:i");
$connection = mysql_connect($host, $user, $pass) or die(mysql_error());
$db = mysql_select_db($db_name, $connection) or die(mysql_error());
if ($action == 'add')
{
$sql1 = "INSERT INTO censure VALUES ('','". $word ."','". $replacement ."','". $date ."','". $hour ."')";
$result1 = mysql_query($sql1,$connection) or die('Erreur SQL insertion: '.mysql_error());
echo "<meta http-equiv=\"refresh\" content=\"0;url=index.php?menu=GuestBookCensure\">\n ";
}
elseif($action == 'del')
{
$sql2 = "DELETE FROM censure WHERE id='". $id ."'";
$result2 = mysql_query($sql2,$connection) or die('Erreur SQL Delete: '.mysql_error());
echo "<meta http-equiv=\"refresh\" content=\"0;url=index.php?menu=GuestBookCensure\">\n ";
}
elseif($action == 'update')
{
$sql3 = "UPDATE censure SET word='". $word ."', replacement='". $replacement ."' WHERE id='". $id ."'";
$result3 = mysql_query($sql3,$connection) or die('Erreur SQL Update: '.mysql_error());
echo "<meta http-equiv=\"refresh\" content=\"10;url=index.php?menu=GuestBookCensure\">\n ";
}
else
{
?>
<form action="index.php?menu=GuestBookCensure&action=add" method="post" name="form">
<table width="100%" class="DivStyle2">
<tr>
<td width="40%" align="right">Word:</td>
<td width="60%"><input type="text" name="word" maxlength="30" size="20" value="" class="input01"></td>
</tr>
<tr>
<td width="40%" align="right">Replace with:</td>
<td width="60%"> <input type="text" name="replacement" maxlength="30" size="20" value="***" class="input01"></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="Send" class="input02">
</td>
</tr>
</table>
<?php
$sql = "SELECT * FROM ". $table_gbook_censure ." ORDER BY id DESC";
$result = mysql_query($sql,$connection) or die(mysql_error());
$total = mysql_num_rows($result);
if ($total == '')
{
echo "<p>No bad words</p>\n";
}
else
{
echo "<p style=\"color: #f00; text-align: center\">There is ". $total ." bad words</p>\n";
//echo "There is $total Rows";
}
?>
<script language="JavaScript" type="text/javascript">
<!--
function conf()
{
return (confirm("Are you sure?"));
}
//-->
</script>
<table width="100%" class="DivStyle2">
<tr>
<td width="20%" align="left">Date</td>
<td width="20%" align="left">Word</td>
<td width="20%" align="left">Replacement</td>
<td width="40%" align="center">Actions</td>
</tr>
<?php
while($censure = mysql_fetch_array($result))
{
$date = $censure['date'];
$hour = $censure['hour'];
$word = $censure['word'];
$replacement = $censure['replacement'];
?>
<tr>
<td width="20%" align="left"><?php echo "$date"; ?> <?php echo "$hour"; ?></td>
<td width="20%" align="left"><input type="text" name="word" maxlength="30" size="20" value="<?php echo "$word"; ?>" class="input01"></td>
<td width="20%" align="left"><input type="text" name="replacement" maxlength="30" size="20" value="<?php echo "$replacement"; ?>" class="input01"></td>
<td width="40%" align="right">
<a href="index.php?menu=GuestBookCensure&action=update&id=<?php echo($censure[id]); ?>" onClick="return conf();">Update</a>
<a href="index.php?menu=GuestBookCensure&action=del&id=<?php echo($censure[id]); ?>" onClick="return conf();">Delete</a>
</td>
</tr>
<?php
}
}
?>
</table>
</form>
<?php echo($censure['id']); ?>
manquait des quotes