bas7320 Posted November 10, 2007 Share Posted November 10, 2007 I am passing various text variables via a URL to a form that uses a command as follows: name="recid" value="<? echo $_GET['recid'] ?>" An example of a recid value that I am passing is 57L2J60)K#LLA:Y however this is being truncated to 57L2J60)K. What can I use to make sure that the full text is captured and not truncated? Steve Link to comment https://forums.phpfreaks.com/topic/76693-pulling-characters-with-get-method/ Share on other sites More sharing options...
MadTechie Posted November 10, 2007 Share Posted November 10, 2007 use urlencode to encode if first then decode it <?php echo '<a href="mycgi?foo=', urlencode($userinput), '">'; ?> more info here http://php.net/manual/en/function.urlencode.php Link to comment https://forums.phpfreaks.com/topic/76693-pulling-characters-with-get-method/#findComment-388271 Share on other sites More sharing options...
kenrbnsn Posted November 10, 2007 Share Posted November 10, 2007 The "#" has a special meaning when it's in a URL. You can try using the urlencode() function: name="recid" value="<?php echo urlencode($_GET['recid']) ?>" MadTechie beat me to it... Ken Link to comment https://forums.phpfreaks.com/topic/76693-pulling-characters-with-get-method/#findComment-388273 Share on other sites More sharing options...
bas7320 Posted November 10, 2007 Author Share Posted November 10, 2007 The "#" has a special meaning when it's in a URL. You can try using the urlencode() function: name="recid" value="<?php echo urlencode($_GET['recid']) ?>" MadTechie beat me to it... Ken That sort of worked however it still truncated at another character, the ")". Any other thoughts? Link to comment https://forums.phpfreaks.com/topic/76693-pulling-characters-with-get-method/#findComment-388282 Share on other sites More sharing options...
kenrbnsn Posted November 10, 2007 Share Posted November 10, 2007 I just did a quick test, the following shows that using urlencode() works: <?php if (isset($_GET['test'])) echo '<pre>' . print_r($_GET,true) . '</pre>'; $str = '57L2J60)K#LLA:Y'; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title></title> </head> <body> <a href="?test=<?php echo $str; ?>">test 1</a><br> <a href="?test=<?php echo urlencode($str); ?>">test 2</a><br> </body> </html> Ken Link to comment https://forums.phpfreaks.com/topic/76693-pulling-characters-with-get-method/#findComment-388403 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.