Jump to content

[SOLVED] Why doesn't this redirect like it should?


h2oskierc

Recommended Posts

I have this php page that updates a record in a MySQL databse, and when it is finished updating I want it to redirect to preview_proof.php?proofID=x, where x is the proof ID number.  The problem is that it doesn't re-direct.  It does update the record, but that is it.

 

<?php
//setup the variables for upload processing script
$uploadDir = '../proofs/images/large/';  //sets the large image directory
$thumbDir = '../proofs/images/small/';   //sets the small image directory
$desThumbWidth = 350;  //sets the desired small image size
$desThumbHeight = 350;  //sets the desired small image size

//process the uploaded files
@ include('../assets/includes/upload_thumb.inc.php');
?>

<?php require_once('../Connections/proofs.php'); ?>
<?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($thumb_name)) {
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "proofDetails")) {
  $updateSQL = sprintf("UPDATE signs SET image=%s WHERE signID=%s",
                       GetSQLValueString($thumb_name, "text"),
                       GetSQLValueString($_POST['signID'], "int"));

  mysql_select_db($database_proofs, $proofs);
  $Result1 = mysql_query($updateSQL, $proofs) or die(mysql_error());
}
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "proofDetails")) {
  $updateSQL = sprintf("UPDATE signs SET `size`=%s, material=%s, sided=%s, colors=%s, cost=%s, notes=%s WHERE signID=%s",
                       GetSQLValueString($_POST['size'], "text"),
                       GetSQLValueString($_POST['material'], "text"),
                       GetSQLValueString($_POST['sided'], "text"),
                       GetSQLValueString($_POST['colors'], "text"),
                       GetSQLValueString($_POST['cost'], "text"),
                       GetSQLValueString($_POST['notes'], "text"),
                       GetSQLValueString($_POST['signID'], "int"));

  mysql_select_db($database_proofs, $proofs);
  $Result1 = mysql_query($updateSQL, $proofs) or die(mysql_error());

}

$colname_signID = "-1";
if (isset($_GET['signID'])) {
  $colname_signID = $_GET['signID'];
}

mysql_select_db($database_proofs, $proofs);
$query_signID = sprintf("SELECT * FROM signs WHERE signID = %s", GetSQLValueString($colname_signID, "int"));
$signID = mysql_query($query_signID, $proofs) or die(mysql_error());
$row_signID = mysql_fetch_assoc($signID);
$totalRows_signID = mysql_num_rows($signID);


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dell Signs & Graphics Proofing System</title>
<link href="../assets/styles/oneColFixCtrHdr.css" rel="stylesheet" type="text/css" />
<script src="../assets/spry/SpryMenuBar.js" type="text/javascript"></script>
<link href="../assets/spry/SpryMenuBarHorizontal_nav.css" rel="stylesheet" type="text/css" />
</head>

<body class="oneColFixCtrHdr">
<?php echo $newLocation; ?>
<div id="container">
  <div id="header">
    <h1>Dell Signs & Graphics</h1>
    <img src="../assets/images/header.jpg" alt="Dell Signs & Graphics" width="780" height="179" />
    <!-- end #header -->
  </div>
  <?php include('../assets/includes/nav.inc.php'); ?>
  <div id="mainContent">
    <h1> Edit Sign in Proof    </h1>
    <form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="proofDetails" id="proofDetails">
    <fieldset>
    <legend>Sign ID is: <?php echo $row_signID['signID']; ?> Proof ID is: <?php echo $row_signID['proofID']; ?></legend>
      <label for="proof"><br />
      <p>Original Image:<br />
      <img src="images/small/<?php echo $row_signID['image']; ?>" /></p>
      <input name="signID" type="hidden" id="signID" value="<?php echo $row_signID['signID']; ?>" />
      Proof Image:</label>
      <input type="file" name="proof" id="proof" />
      <input name="image" type="hidden" id="image" value="<?php echo $row_signID['']; ?>" />
      <p>
        <label for="size">Sign Size:</label>
        <input name="size" type="text" id="size" value="<?php echo $row_signID['size']; ?>" />
      </p>
      <p>
        <label>
        <input <?php if (!(strcmp($row_signID['sided'],"s"))) {echo "checked=\"checked\"";} ?> type="radio" name="sided" value="s" id="sided_0" />
Single Sided</label>
        <br />
        <label>
        <input <?php if (!(strcmp($row_signID['sided'],"d"))) {echo "checked=\"checked\"";} ?> type="radio" name="sided" value="d" id="sided_1" />
Double Sided</label>
      </p>
      <p>
        <label for="colors">Sign Colors:</label>
        <input name="colors" type="text" id="colors" value="<?php echo $row_signID['colors']; ?>" />
      </p>
      <p>
        <label for="material">Sign Materials:</label>
        <input name="material" type="text" id="material" value="<?php echo $row_signID['material']; ?>" />
      </p>
      <p>
        <label for="cost">Sign Cost:</label>
        <input name="cost" type="text" id="cost" value="<?php echo $row_signID['cost']; ?>" />
      </p>
      <p>
        <label for="notes">Sign Notes:<br />
        <br />
        </label>
        <textarea name="notes" id="notes" cols="45" rows="5"><?php echo $row_signID['notes']; ?></textarea>
      </p>
      </fieldset>
      <p>
        <input type="submit" name="create" id="create" value="Edit Sign" />
      </p>
      <input type="hidden" name="MM_update" value="proofDetails" />
    </form>
  </div>
  <?php include('../assets/includes/footer.inc.php'); ?>
<!-- end #container --></div>

</body>
</html>
<?php
mysql_free_result($signID);

@ mysql_free_result($getProofID);
?>

 

Thanks for looking at this again.  I know it is a TON of code to decipher when you cannot test it yourself.

Okay,

 

I reverted back to a previous version of the code, as I found some other bugs, and added the header in there:

 

  if (isset($_SERVER['QUERY_STRING'])) {
header('location: preview_proof.php?proofID='.$row_signID['proofID']);
exit();

}

 

The script is re-directing to http://dellsigns/proofs/preview_proof.php?proofID= (it isn't parsing the variable correctly as the ' is before the variable?)

 

So I tried to set it up using a print funtion:

if (isset($_SERVER['QUERY_STRING'])) {
header(sprintf('location: preview_proof.php?proofID=%s', $row_signID['proofID']));
exit();
}

 

What is wrong with that code?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.