Skip to main content
Participant
February 27, 2012
Question

Update a record and back to a specific page

I'm using a simple dreamweaver default script to update a record:

$updateGoTo = "cadastro_cliente.php?id=".$row_rsEditar_Receita['id_cliente'];

  if (isset($_SERVER['QUERY_STRING'])) {

    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";

    $updateGoTo .= $_SERVER['QUERY_STRING'];

  }

  header(sprintf("Location: %s", $updateGoTo));

But it's time to redirect the page to the specified page, the script is not using the id number I want.

The script use the same id of the edit page.

This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

Participating Frequently
February 28, 2012

What ID do you want to use?

You are setting the goto querystring to use the id from your recordset rsEditar. But you are also appending the former querystring value. So you may have conflicting name/values pairs in your querystring.

Translate
Participant
February 28, 2012

Bregent,

I found a solution:

In the form

<input type="hidden" name="id_cliente" value="<?php echo $row_rsEditar_Receita['id_cliente']; ?>" />

In the script:

$updateGoTo = "cadastro_cliente.php?id=".$_POST['id_cliente'];

  header(sprintf("Location: %s", $updateGoTo));

Thanks!

Translate
Participating Frequently
February 28, 2012

Yes, exactly. This will eliminate the multiple instances of a name/value pairs you had in the querystring.

Translate