Problem with php url

Asked

Viewed 260 times

0

I have a problem with my url, when I go to the pagina php-detailed. it shows in the url the id of the project being detailed, thus:

http://localhost/opentag/project-detailed.php? id=14

When I go to the page php project change. if all goes well, I’ll go to the php-detailed. passing the id of the project I changed:

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

The problem is that the urls mix and become a mess and the page detailed design can’t get the project.

http://localhost/opentag/project-detailed.php? id=%27()%27

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

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

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

1 answer

1


You are using simple quotes in the wrong place, see information here, right here:

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

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

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

To correct 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());
  • Oops ! vlw worked

Browser other questions tagged

You are not signed in. Login or sign up in order to post.