I'm trying to redirect the user back to a certain URL after a form submit with the following
header( "refresh:3;url=http://www.XXXX.XXXX/XXXXX/addshotstogamePart2.php?gameNo=$gameNo&roundName=$roundName" );
which should be something like this
http://XXXX.XXXX/XXXX/addshotstogamePart2.php?gameNo=24&roundName=Round+1
but what i'm getting is
http://XXX.XXX/XXX/addshotstogamePart2.php?gameNo=24&roundName=Round%25201
How can i avoid that or fix it?
It looks that Round+1 gets url encoded.
Because + is not a valid url symbol.
You can use other symbol, for example ...&roundName=Round_1
Or use just number ...&roundName=1
You can use no symbol at all ...&roundName=Round1 but then you need to parse that number out of string.
Related
kindly I have two links,
when using both of the links in another page, the first link is decoded automatically by GET Method and the second didn't.
the problem is that if there is a space in any attribute, the get don't decode automatically the URL and if there are no spaces, the get automatically decoding the URL which is the correct behaviour
tip : the only encoded attribute is BodyStr and encoded via URLENCODE PHP function.
another tip: the difference between both is the space in subjectStR Attribute
I want to know why spaces in URL prevent GET Global Variable from automatically decoding all the attributes
$message=urlencode($message);
http://localhost/test4.php?me=ahmed&y=1&clientid=55&default=1&Subjectstr=**Email From Contactuspage`**&BodyStr=$message
http://localhost/test4.php?me=ahmed&y=
1&clientid=55&default=1&Subjectstr=**EmailFromContactuspage**&BodyStr=$message
Space isn't allowed in URL query strings. If you put an unencoded space in SubjectStr, the URL ends at that point, so the server never sees the BodyStr parameter.
You need to URL-encode SubjectStr. Replace the spaces with + or %20.
$message=urlencode($message);
$url = "http://localhost/test4.php?me=ahmed&y=1&clientid=55&default=1&Subjectstr=Email+From+Contactuspage&BodyStr=$message"
The reason why it stops at space is because of the HTTP protocol. The client sends:
GET <url> HTTP/1.1
This request line is parsed by looking for the space between the URL and the HTTP version token. If there's a space in the URL, that will be treated as the end of the URL.
i am processing a activation link.which looks like this.
localhost/actvte/validate.php?type=activate&geo=define&
value=227755RYQBENU5G8WE7RFPO6CD6Z#MJ1H1FA#G#IZWZ53903
&target=loaded&resrc=G6MYMI2R67727229911380184297841084713071U8VUYIGR
&master=user#gmail.com
but when i use $_get['value'] i get o/p only "227755RYQBENU5G8WE7RFPO6CD6Z".after this whole link becomes useless.if i do
echo $_get['target']; or echo $_get['master'];
it says undefined variable 'target' or 'master'.
so how can i process this large link.
What you should do is use the urlencode() function in PHP on the string before putting it in the GET. This way your string becomes 227755RYQBENU5G8WE7RFPO6CD6Z%23MJ1H1FA%40G%23IZWZ53903 and not 227755RYQBENU5G8WE7RFPO6CD6Z#MJ1H1FA#G#IZWZ53903 as special characters cannot be used in the query string.
Hashes for example will never even be send by the browser to the server, so everything behind that will not reach you.
Please look at RFC 3986 for more information about the URI syntaxing (including hashes).
By not using or properly encoding the fragment identifier (#).
You should not use # in the URL but encode it some way, or use another character.
The first # in a URL indicates the start of the fragment identifier. If you want to send it as data rather then a separator component of a URL then you need to express it as %23.
I have a form I'm trying to submit to a database. Upon successful submission I would like the page to redirect to a page containing the submitted data. I'm doing this with a query string like:
header("location:palette.php?colID=$title");
Which is producing a URL like: palette.php?colID=Funky%20Colours
Is it possible for the PHP header redirect to redirect to a query like:
palette.php?colID=Funky-Colours
To produce a URL like: palette.php?colID=Funky-Colours
If so, can someone provide an example
You can do this by simply doing:
header('Location: palette.php?colID='.urlencode(str_replace(' ','-',$title)));
But in your palette.php, $_GET['colID'] will be receiving Funky-Colours instead of Funky Colours. So you need to use str_replace() again to convert the dashes to spaces.
So, another question would be, what do you intend to do with those column IDs with dashes? For instance, the $title submitted is Something-With-Dashes, your script would turn these dashes into spaces. But to answer your question, yes, it is possible to do this using str_replace().
I need to send URL from one page which contains a form, to another page to check whether the link exist in my database or not. so there are URLs with special characters such as '+' '%' and some part of the URL is html encoded, and some are not. so I cannot encode and send the URL to decode from the receiver page.
$('#searchbutton').click(function(){
var url = $('#urltext').val();
$('#datatodiv').load("searchlink.php?url="+url);
});
When I input the URL "http://www.example.com/ae2/STUDIO+CHANNEL+PRO/" which received at the searchurl.php page as "http://www.example.com/ae2/STUDIO CHANNEL PRO/" where the '+' is changed to empty space. There are cases in which encoded data such as "%20" etc used.
You can use encodeURI() to encode a url:
var url = encodeURI($('#urltext').val());
Example fiddle
This will at least ensure that the URL values being sent have a consistent encoding.
Try to use PHP functions -
base64_encode()
base64_decode()
I saw some request like
www.example.com/start.php?404;http://www.example.com:80
but unfortunately can't understand if it is a valid url or how it will work.
www.example.com/start.php?404
and
http://www.example.com:80
and
www.example.com/start.php?404;http://www.example.com:80
are all valid URLs. But since ; is not a reserved symbol, it needs to be URL encoded. See Characters allowed in a URL for the list of characters allowed in a URL.
I don't think its a valid url. It redirects you to a 404 page. The http://www.example.com:80 is probably wrong set so it enters a complete url at the end of the already standing url.
Maybe i am wrong.