Jump to content

GET query


aristotle15

Recommended Posts

Hi, I have written a code that take the GET contents of a URL , i.e after the ? sign and outputs it as a csv file.

eg - ....../xyz.php?str=<tr><td>c1</td><td>c2</td><td>c3..........c7</tr></td>

 

$input = $_GET['str'];

.........

............

......

 

 

output should be as - c1,c2,c3,c4.... so on

well , i have written a code for that and it works wonderfully except that if the url contains '&' and '#'(hidden fields) in the columns , the script malfunctions coz they act as delimiters.How do I take care of that? how to fetch the contents of the URL so that the & and # dont create a problem?

Please help.. :)

 

Link to comment
https://forums.phpfreaks.com/topic/225478-get-query/
Share on other sites

you need to use urlencode for the hash and you need to escape the $ symbol with \

 

like this for example

 

testpage.php

<?php
if(isset($_GET['test'])) {
echo $_GET['test']." is printing my data";
} else {
$works=urlencode("yes\$this#works");
echo "<a href='testpage.php?test=$works'>click</a>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/225478-get-query/#findComment-1164311
Share on other sites

What I want is-

if i enter the url - ...../xyz.php?str='abcdefg' in my browser and press enter,

 

'abcdefg' goes into an array ,

Its very simple with $_GET['str']

 

BUT

 

if & or # come in the 'str' , the string is broken before those characters.

Is there any way I could escape & and # in the url so that I could use the contents of the url...

i.e some way other than $_GET['str']

 

Link to comment
https://forums.phpfreaks.com/topic/225478-get-query/#findComment-1164375
Share on other sites

I am jusy typing it in the browser address bar... it will be encoded in some button later on.. but what i want is this only... the columns i pass... in str    , eg.-  ...?str='<tr><td>c1</td><td>c2</td><td>c3</td></tr>' are to be made into csv format..which i ve done but my problem is that if the columns i pass contain # or & , the csv line breaks before that character.

How to 'treat' the input before using $_GET[] coz  $_GET[] cannot take any string that has # or & in it.

 

Link to comment
https://forums.phpfreaks.com/topic/225478-get-query/#findComment-1164872
Share on other sites

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.