Reputation: 866
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.
Upvotes: 1
Views: 554
Reputation: 337560
You can use encodeURI()
to encode a url:
var url = encodeURI($('#urltext').val());
This will at least ensure that the URL values being sent have a consistent encoding.
Upvotes: 1
Reputation: 16086
Try to use PHP functions -
base64_encode()
base64_decode()
Upvotes: 1