Codice PHP:
<?php require_once('../Connections/prova.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"] == "form1")) {
$insertSQL = sprintf("INSERT INTO tabella_dettagli (immagine1) VALUES (%s)",
GetSQLValueString($_POST['immagine1'], "text");
mysql_select_db($database_prova, $prova);
$Result1 = mysql_query($insertSQL, $prova) or die(mysql_error());
$img1 = $_POST['img1']; // QUESTO VALORE LO OTTENGO DAL FORM DELLA PAGINA PRECEDENTE
$insertGoTo ="inseriscifase4.php?var1=<? echo "$img1"; ?>"; // QUI HO BISOGNO DI SCRIVERE
// IL VALORE DI img1 CHE COME HO DETTO OTTENGO DALLA PAGINA PRECEDENTE MA NEL BROWSER NON ME LO SCRIVE
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<?php
mysql_select_db($database_prova, $prova);
$query_inserisci = "SELECT * FROM tabella_dettagli";
$inserisci = mysql_query($query_inserisci, $prova) or die(mysql_error());
$row_inserisci = mysql_fetch_assoc($inserisci);
$totalRows_inserisci = mysql_num_rows($inserisci);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html>
<head>
<title></title>
</head>
<body>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table>
<tr>
<td>Immagine1:</td>
<td><input type="text" name="immagine1" value="<?php echo "$img1"; // DEVE SCRIVERE
//LO STESSO VALORE CHE OTTIENE DALLA PAGINE PRECEDENTE: QUESTO FUNZIONA! ?>"></td>
</tr>
<tr valign="baseline">
<td><input type="submit" value="Inserisci record"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
</body>
</html>
<?php
mysql_free_result($inserisci);
?>
Mi aiutate a correggere questo codice?
quello che non mi funziona è questo
$insertGoTo ="inseriscifase4.php?var1=<? echo "$img1"; ?>"; nel browser della pagina inserisci4.php mi compare solo inseriscifase4.php?var1= ovvero non passa la variabile img1 che se invece la richiamo con un echo passa correttamente dalla pagina precedente!!
HELP! HELP! HELP! HELP! HELP!