Loosing variable from the _GET[]

I cant figure out what is happening here, I have this page which echoes out all the GET variables,


Then, I try to use them on the page,

image
As you can see, that worked fine.
But when I tried to add the variables into the header like

header("location: move_device.php?Search=".$search."&rack_id=".$from_rack_id."&Device=".$device_id."&move_id=".$last_id);


It looks like im missing the + in the search variable, how do I allow for that when I prepare the variable?

$search = addslashes($_POST['search']);

cause that aint doing it

Isn’t that URL-encoding? Adding slashes into a URL doesn’t sound like a good idea.

1 Like

yes, that worked.
https://www.php.net/manual/en/function.urlencode.php

got rid of the addslashes thing

1 Like

‘#’ - prefix of URL part (anchor). E.g.: www.some-domain.com/index.php#comments.

So, sure you will have nothing except of “search”.

1 Like

See php’s http_build_query() for building the query string part of a url. It automatically urlencodeds the values.

1 Like

I would have broken it down to smaller steps and hopefully highlight the failure:

<?php declare(strict_types=1);
Error_reporting(-1);
Ini_set('display_errors','true');

$tmp = "?Search= search
. "&rack_id="
. $from_rack_id
."&Device="
.$device_id
."&move_id="
.$last_id;
echo $tmp;
// Try passing the $tmp parameters to move_device.php

// Etc
// header("location: move_device.php?Search=".$search."&rack_id=".$from_rack_id."&Device=".$device_id."&move_id=".$last_id);
1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.