URL ex: gamob.net/token?#access_token=EAAKJnZAm
Code PHP:
eg 1:
$token = $_GET['access_token'];
echo $token;
eg 2:
$token = $_GET['#access_token'];
echo $token;
eg 3:
$token = $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
echo $token;
All can't get value in Url. Thank you!
I think the char # is reserved to mark anchor.
I have never seen it in GET parameters
try this ex url : gamob.net/token?access_token=EAAKJnZAm
And acces the param like that : $_GET['access_token'];
Also ?is to mark the beginning of the params and & separation between parametres
The variable # can only be retrieved by Javascript.
Look this exemple: how to save facebook access token after success
Related
I have this URL in my page
https://www.albaama.com/search.php?qry=Fashion%20&%20Clothing
and I use this code below to echo out the value of the variable 'qry'
<?php
if (isset($_GET['qry'])) {
echo $_GET['qry'];
}
else {
echo "";
}
?>
but whenever I echo it, I only get Fashion instead of Fashion & Clothing.
please how do I get the complete value?
This query string: https://www.albaama.com/search.php?qry=Fashion%20&%20Clothing
Translates to this:
URL: https://www.albaama.com/search.php
Parameter 1: qry="Fashion " ("Fashion" and a trailing space)
Parameter 2: " Clothing" ("Clothing" and a leading space)
The problem is that & introduces a second parameter.
You need to urlencode() the entire string "Fashion & Clothing"
i'm trying to properly validate external url from a codeigniter 3 view.
I have in my db an url like this :
http://www.example.com/content.php?id=test&article=3
and i want to make a link like this one ->
http://www.example.com/content.php?id=test&article=3
I tried this :
<?php
if (isset($c_url_redir)){
$c_url_redir = 'http://www.example.com/content.php?id=test&article=3';
echo anchor(htmlspecialchars($c_url_redir), "go", 'class="pure-button pure-button-primary" target="_blank"');
}
?>
but i have the same url as the first one.
Could you help me?
Try using url_encode() on just the get variables. Personally, I'd have the first part of the URL assigned to a variable then tack on the url_encoded get variables e.g.
$c_url_redir = 'http://www.example.com/content.php';
$get_variables = url_encode('id=test&article=3');
echo anchor($c_url_redir . '?' . $get_variables, "go", 'class="pure-button pure-button-primary" target="_blank"');
I have the simple PHP script:
<?php
$url = $_REQUEST['url'];
if (preg_match('/\b(https?|ftp):\/\/*/', $url) !== 1) die;
echo (file_get_contents($url));
?>
I am trying to echo the page:
http://forum.bodybuilding.com/showthread.php?t=162984431&page=10
but the echo shows:
http://forum.bodybuilding.com/showthread.php?t=162984431
example:
http://www.kylesbox.com/forumbuddy/fetch/fetch.php?url=http://forum.bodybuilding.com/showthread.php?t=162984431&page=10
I am not a PHP expert but I think this has something to do with persistent URLs? How would I go about fixng this so the echo displays everything after the & symbol as well? I do have cURL installed on my server if that helps. Thanks!
Here the "&" sign is part of query string element. So it will avoid to get value from first "&". We can two more lines on your script to get the work done.
<?php
$query=$_SERVER['QUERY_STRING']; //get the full query string in url
$query_arr=explode("url=",$query); //split the string by first get key
$url = $query_arr[1]; //take second parameter as url to be loaded
if (preg_match('/\b(https?|ftp):\/\/*/', $url) !== 1) die;
echo (file_get_contents($url));
?>
The she script available at following url as working script.
http://sugunan.net/demo/fetch.php?url=http://forum.bodybuilding.com/showthread.php?t=162984431&page=10
I'm working on a code like this:
<?php
$id=$_POST['id'];
$url_tag = $_POST['url_tag'];
$url_back = 'https://www.page.example.com/page.php?';
$query='id='.$id.'&url_tag='.$url_tag;
$url = $url_back.$query;
echo 'Look how this url shows up: '.$url;
echo '<a href='.$url.'>Click here</a>';
?>
This is, the page receives two POST parameters. Then prepare a link to https://www.page.example.com/page.php? and I append those two parameters as GET parameters with the ids id and url_tag respectively.
Then I display how the whole link looks like. It shows up correctly, in this case https://www.page.example.com/page.php?id=ID&url_tag=URL_TAG, where ID and URL_TAG are the actual values received as POST parameters.
However, when I click on the 'Click here' link, it redirects me to https://www.page.example.com/page.php?, which is the url without any GET parameter.
Why is that happening and how would I solve it? I've tried to feed HREF with urlencode($url) instead, but it redirects me to an address flooded with undesired characters...
Any idea? Thank you!
Try to replace the last line of your code by this:
echo 'Click here';
It should work.
Try using http_build_query(), it takes care of any URL character compatibility issues for you...
// assuming you've already checked and validated your $_POST parameters
$query = http_build_query(array(
'id' => $_POST['id'],
'url_tag' => $_POST['url_tag']
));
$url = 'https://www.page.example.com/page.php?' . $query;
?>
Click here
I'm trying to filter my URL value become hidden due to security purpose. Any solution or method to do that?
I'm doing it this way:
<html
<a href='www.iluvpromo.com/unsubscribe.php?email=$email'>
</html>
and the URL is displayed like this:
http://www.iluvpromo.com/unsubscribe.php?email="email_address"
but I want it to be displayed like this:
http://www.iluvpromo.com/unsubscribe.php
you can use some encryption code to encrypt your parameter which cannot understand by user.
$myData = array('foo'=>1, 'bar'=>'hax0r');
$arg = base64_encode( json_encode($myData) );
http:www.iluvpormo.com/parameter=$arg
and back:
$myData = json_decode( base64_decode( $_GET['secret'] ) );
You can do similar 'action' in several ways:
md5(email), and user wont see it in cleartext
you can use session (if user is logged in)
pass user id (not that good idea thou, users can guess that easily)
make a POST request with params (not link, form is used for that)
You may use session :
in the first page :
<?php
session_start();
$_SESSION['email']=$email;
?>
in the second page :
if(isset($_SESSION['email']))
//do sth
//unset($_SESSION['email']); to destroy the session
another way is to use post variable :
in the first pge :
$_POST['email'] = $email;
in the second page:
if( $_POST["email"])
//do something
another way is using hlink :
echo hlink ("hyperlinktext", "email", "http://www.iluvpromo.com/unsubscribe.php", "funkyclass", $email);
instead of this:
<a href='http://www.iluvpromo.com/unsubscribe.php?email=$email' class='funkyclass'>hyperlink text</a>
Alternatively you could encrypt your querystring or post the value in a form (visible in source though).