par
dmx-moteur » 17 mai 2005, 17:35
Merci de cette réponse mais en tant que grand débutant cela ne m'éclaire pas beaucoup.
Sur ma page d'insertion (code édité par Dreamweaver MX 2004):
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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_insert"])) && ($_POST["MM_insert"] == "offre")) {
$insertSQL = sprintf("INSERT INTO offres (Affiche, `DATE`, INTITULE, DESCRIPTIF) VALUES (%s, %s, %s, %s,)",
GetSQLValueString($_POST['Affiche'], "int"),
GetSQLValueString($_POST['date'], "date"),
GetSQLValueString($_POST['intitule'], "text"),
GetSQLValueString($_POST['descriptif'], "text"));
mysql_select_db($database_emploi, $emploi);
$Result1 = mysql_query($insertSQL, $emploi) or die(mysql_error());
$insertGoTo = "recap_offre.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
et sur ma page de récap :
<?php
// on récupère les valeur du formulaire précédent pour les afficher dans la page
$VARdate = $_POST['date'];
$VARintitule = $_POST['intitule'];
$VARdescriptif = $_POST['descriptif'];
?>
dans mon code HTML :
<table >
<tr>
<td width="30%"><strong>Date de l'offre :</strong></td>
<td class="bleu"><? echo ($VARdate); ?></td>
</tr>
<tr>
<td width="30%"><strong class="orange">Intitulé du poste :</strong></td>
<td valign="top" class="orange"><? echo StripSlashes($VARintitule); ?></td>
</tr>
<tr>
<td width="30%" valign="top"><strong>Descriptif :</strong></td>
<td valign="top" class="bleu"><? echo StripSlashes($VARdescriptif); ?></td>
</tr>
Mais cela ne marche pas : j'obtiens l'erreur "undefined index" ....
Merci de votre aide !!
Merci de cette réponse mais en tant que grand débutant cela ne m'éclaire pas beaucoup.
Sur ma page d'insertion (code édité par Dreamweaver MX 2004):
[php]
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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_insert"])) && ($_POST["MM_insert"] == "offre")) {
$insertSQL = sprintf("INSERT INTO offres (Affiche, `DATE`, INTITULE, DESCRIPTIF) VALUES (%s, %s, %s, %s,)",
GetSQLValueString($_POST['Affiche'], "int"),
GetSQLValueString($_POST['date'], "date"),
GetSQLValueString($_POST['intitule'], "text"),
GetSQLValueString($_POST['descriptif'], "text"));
mysql_select_db($database_emploi, $emploi);
$Result1 = mysql_query($insertSQL, $emploi) or die(mysql_error());
$insertGoTo = "recap_offre.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
[/php]
et sur ma page de récap :
[php]
<?php
// on récupère les valeur du formulaire précédent pour les afficher dans la page
$VARdate = $_POST['date'];
$VARintitule = $_POST['intitule'];
$VARdescriptif = $_POST['descriptif'];
?>[/php]
dans mon code HTML :
[php]
<table >
<tr>
<td width="30%"><strong>Date de l'offre :</strong></td>
<td class="bleu"><? echo ($VARdate); ?></td>
</tr>
<tr>
<td width="30%"><strong class="orange">Intitulé du poste :</strong></td>
<td valign="top" class="orange"><? echo StripSlashes($VARintitule); ?></td>
</tr>
<tr>
<td width="30%" valign="top"><strong>Descriptif :</strong></td>
<td valign="top" class="bleu"><? echo StripSlashes($VARdescriptif); ?></td>
</tr>
[/php]
Mais cela ne marche pas : j'obtiens l'erreur "undefined index" ....
Merci de votre aide !!