Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Update a record and back to a specific page

New Here ,
Feb 27, 2012 Feb 27, 2012

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.

TOPICS
Server side applications
542
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 27, 2012 Feb 27, 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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 28, 2012 Feb 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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 28, 2012 Feb 28, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 28, 2012 Feb 28, 2012
LATEST

Thanks bregent. Sometimes, we need to understand the code instead just copy and paste its

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines