Jump to content

Pulling Characters with GET method


bas7320

Recommended Posts

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

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?

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.