Prévisualisation + insertion de données

Eléphant du PHP | 95 Messages

13 mai 2005, 17:58

Bonjour,

je souhaiterais, à partir d'un formulaire d'insertion, envoyer l'utilisateur sur une page récapitulative de sa saisie en même temps que l'on procède à l'insertion des données des champs dans la base.

Qqun a une idée ?

Merci par avance.

ViPHP
fab
ViPHP | 2657 Messages

13 mai 2005, 18:01

tu affiches les variables rien de plus compliqué ...

Eléphant du PHP | 95 Messages

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&eacute; 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 !!