BoarderLine Posted November 11, 2009 Share Posted November 11, 2009 Hi. I have a hyperlink <a href="Train_Direct.php?recordID=<?php echo $row_rsTrains['trainID']; ?>&dtl=<?php echo $row_rsTrains['train_dtlID']; ?>">VIEW</a> Which is redirecting the user depending on their browser resolution:- this is the content of Train_Direct.php. <?php function setUrlVariables() { $arg = array(); $string = "?"; $vars = $_GET; for ($i = 0; $i < func_num_args(); $i++) $arg[func_get_arg($i)] = func_get_arg(++$i); foreach (array_keys($arg) as $key) $vars[$key] = $arg[$key]; foreach (array_keys($vars) as $key) if ($vars[$key] != "") $string.= $key . "=" . $vars[$key] . "&"; if (SID != "" && SID != "SID" && $_GET["PHPSESSID"] == "") $string.= htmlspecialchars(SID) . "&"; return htmlspecialchars(substr($string, 0, -1)); } ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Stuff2do - Redirect</title> <script language="Javascript"> if (screen.width <= 1023) { document.location = "Training.php<?php echo setUrlVariables(); ?>"; } if (screen.width > 1024) { document.location = "Training_Display.php<?php echo setUrlVariables(); ?>"; } </script> </head> <body> </body> </html> However when redirected to the final page the URL Variables are no longer separated with the & symbol they are replaced with &. Can anyone please help me with why this may be happening? I have tried using & and also %26 in the original link however still no luck. Also urlencode() used in the redirect page also gave no joy :-( Link to comment https://forums.phpfreaks.com/topic/181186-solved-url-variable-problems-from-redirect-page/ Share on other sites More sharing options...
.josh Posted November 12, 2009 Share Posted November 12, 2009 it's the htmlspecialchars that is doing it. It converts special chars (like that &) to their html entity. You have it wrapped around $string in your return. Link to comment https://forums.phpfreaks.com/topic/181186-solved-url-variable-problems-from-redirect-page/#findComment-955949 Share on other sites More sharing options...
BoarderLine Posted November 12, 2009 Author Share Posted November 12, 2009 Nice! thanks Crayon Violent. All good now. Appreciate ur help. Link to comment https://forums.phpfreaks.com/topic/181186-solved-url-variable-problems-from-redirect-page/#findComment-955967 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.