J'ai créé un formulaire de modifiacation avec des champs de type longtext.
lorsque je fais une modification du texte cela fonctionne parfaitement, par contre, j'ai créé un 2eme forulaire pour supprimer le contenu d'un champ de nom de photo automatiquement en cliquant sur un bouton .
Là, la suppression du contenu du champ fonctionne bien, mas le probleme c'est je perd les 3/4 du contenu d'un champslongtext et pour moi il n'y a aucune raison que cela arrive.
Je suppose donc que j'ai fais une erreur quelque part.
Est ce que quelqu'un pourrait m'aider, merci d'avance
Mon code PHP :
<?php require_once('../../../Connections/base.php'); ?><?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "administrateur";
$MM_donotCheckaccess = "false";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && false) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "../../menu2.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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_update"])) && ($_POST["MM_update"] == "modiftexte")) {
$updateSQL = sprintf("UPDATE w4w_situation SET ville=%s, presentation_fr=%s, presentation_en=%s, resum_fr=%s, resum_an=%s, photo1=%s, photo2=%s WHERE id_ville=%s",
GetSQLValueString($_POST['ville'], "text"),
GetSQLValueString($_POST['presentation_fr'], "text"),
GetSQLValueString($_POST['presentation_en'], "text"),
GetSQLValueString($_POST['resum_fr'], "text"),
GetSQLValueString($_POST['resum_an'], "text"),
GetSQLValueString($_POST['photo1'], "text"),
GetSQLValueString($_POST['photo2'], "text"),
GetSQLValueString($_POST['id_ville'], "int"));
mysql_select_db($database_base, $base);
$Result1 = mysql_query($updateSQL, $base) or die(mysql_error());
$updateGoTo = "details.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "supprphoto1")) {
$updateSQL = sprintf("UPDATE w4w_situation SET ville=%s, presentation_fr=%s, presentation_en=%s, resum_fr=%s, resum_an=%s, photo1=%s, photo2=%s WHERE id_ville=%s",
GetSQLValueString($_POST['ville'], "text"),
GetSQLValueString($_POST['presentation_fr'], "text"),
GetSQLValueString($_POST['presentation_en'], "text"),
GetSQLValueString($_POST['resum_fr'], "text"),
GetSQLValueString($_POST['resum_an'], "text"),
GetSQLValueString($_POST['photo1'], "text"),
GetSQLValueString($_POST['photo2'], "text"),
GetSQLValueString($_POST['id_ville'], "int"));
mysql_select_db($database_base, $base);
$Result1 = mysql_query($updateSQL, $base) or die(mysql_error());
$updateGoTo = "modif.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_modif = "-1";
if (isset($_GET['id_ville'])) {
$colname_modif = $_GET['id_ville'];
}
mysql_select_db($database_base, $base);
$query_modif = sprintf("SELECT * FROM w4w_situation WHERE id_ville = %s", GetSQLValueString($colname_modif, "int"));
$modif = mysql_query($query_modif, $base) or die(mysql_error());
$row_modif = mysql_fetch_assoc($modif);
$totalRows_modif = mysql_num_rows($modif);
?>
et mon code formulaire <table width="700" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="37" colspan="2" align="center" bgcolor="#0000FF"><span class="Style1 Style2">Modification de <?php echo $row_modif['ville']; ?></span></td>
</tr>
<tr>
<td width="50%">Résumé en français</td>
<td width="50%">Résumé en anglais</td>
</tr>
<form id="modiftexte" name="modiftexte" method="POST" action="<?php echo $editFormAction; ?>">
<tr>
<td><textarea name="resum_fr" cols="40" rows="6" id="resum_fr"><?php echo $row_modif['resum_fr']; ?></textarea></td>
<td><textarea name="resum_an" cols="40" rows="6" id="resum_an"><?php echo $row_modif['resum_an']; ?></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Description en français</td>
<td>Description en anglais</td>
</tr>
<tr>
<td><textarea name="presentation_fr" cols="40" rows="15" id="presentation_fr"><?php echo $row_modif['presentation_fr']; ?></textarea></td>
<td><textarea name="presentation_en" cols="40" rows="15" id="presentation_en"><?php echo $row_modif['presentation_en']; ?></textarea></td>
</tr>
<tr>
<td height="46" colspan="2" align="center" valign="middle"><label for="button"></label>
<input name="id_ville" type="hidden" id="id_ville" value="<?php echo $row_modif['id_ville']; ?>" />
<input name="ville" type="hidden" id="ville" value="<?php echo $row_modif['ville']; ?>" />
<input name="photo1" type="hidden" id="photo1" value="<?php echo $row_modif['photo1']; ?>" />
<input name="photo2" type="hidden" id="photo2" value="<?php echo $row_modif['photo2']; ?>" />
<input type="submit" name="button" id="button" value="Envoyer" /></td>
</tr>
<input type="hidden" name="MM_update" value="modiftexte" />
</form>
<tr>
<td><table width="200" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><img src="../../upload/photo_situation/<?php echo $row_modif['photo1']; ?>" alt="#" width="200" /></td>
</tr>
<tr>
<td><?php echo $row_modif['photo1']; ?></td>
</tr>
<tr>
<td align="center"><form id="supprphoto1" name="supprphoto1" method="POST" action="<?php echo $editFormAction; ?>">
<input name="id_ville" type="hidden" id="id_ville" value="<?php echo $row_modif['id_ville']; ?>" />
<input name="ville" type="hidden" id="ville" value="<?php echo $row_modif['ville']; ?>" />
<input name="presentation_fr" type="hidden" id="presentation_fr" value="<?php echo $row_modif['presentation_fr']; ?>" />
<input name="presentation_en" type="hidden" id="presentation_en" value="<?php echo $row_modif['presentation_en']; ?>" />
<input name="resum_fr" type="hidden" id="resum_fr" value="<?php echo $row_modif['resum_fr']; ?>" />
<input name="resum_an" type="hidden" id="resum_an" value="<?php echo $row_modif['resum_an']; ?>" />
<input name="photo1" type="hidden" id="photo1" value="" />
<input name="photo2" type="hidden" id="photo2" value="<?php echo $row_modif['photo2']; ?>" />
<input type="submit" name="supprpho1" id="supprpho1" value="Supprimer" />
<input type="hidden" name="MM_update" value="supprphoto1" />
</form>
</td>
</tr>
</table></td>
<td> </td>
</tr>
</table>
Merci encore