Problem with url in php

0

I have a problem with my url, when I go to the project-detailed.php page it shows in the url the project id being detailed, like this:

  

link

When I go to the alter-project.php page if all goes well, I go to the detailed-project.php page by passing the project id that I changed:

header("Location: projeto-detalhado.php?id='$projeto->getId()'");

The problem is that urls mingle and become a mess and the project-detailed page can not fetch the project.

  

link

NOTE: I'm getting the project id via get to do the search and list the details of it.

$projeto = $projetoDAO->buscaProjetoPorId($_GET['id']);

Is there any function for me to clear the url, and it only has what I sent in the header ()?

    
asked by anonymous 25.03.2017 / 13:35

1 answer

1

You are using single quotation marks in the wrong place, see information here , right here:

header("Location: projeto-detalhado.php?id='$projeto->getId()'");

You are inserting two ' into the link, it has the code %27 , as you can see here and here , so the link will automatically be by the browser :

/projeto-detalhado.php?id=%27[ALGUMA-COISA]%27

To fix the %27 remove the ' , you can:

header("Location: projeto-detalhado.php?id={$projeto->getId()}");

If you prefer, you can use:

header('Location: projeto-detalhado.php?id='.$projeto->getId());
    
25.03.2017 / 14:47