I want to use the URL of the link that was clicked in a VB.net program. How can I take the url from my browser url bar and use it in my PHP program?
Example:
VB.net - click link then open using a web browser
url: www.something.com/id=^%$##&var2=13lfhd3f4gt
PHP - put the link in a variable or something so that I can use explode command to get the id and var2 from the URL itself
I need those variables to output a certain value from my database.
This question has the answer that you are looking for, for getting the url in PHP:
Get the full URL in PHP
Though for getting id and var2, it would be simpler to just use the $_GET variable in php. Then you don't have to explode the url and process it. Just change the '/' after 'com' to a ? like:
www.something.com?id=^%$##&var2=13lfhd3f4gt
You can do this using eg. $_SERVER global variable. Please refer to the manual
Related
Let me explain with an example:
I have this link (php file): http:// mywebsite.com/abc/?id=fasfsa&id2=derp
On the Php I have the 2 variables id and id2.
So I'm using another php file to post the link but he has other variables and it doesn't consider mine.
Let me show how:
http: //website.com/publish.php?url=http: //mywebsite.com/abc/?id=fasfsa&id2=derp&linkname=blabla&image=http: //google.com/g.jpg
This is the sintax of publish.php. I can't edit that file. when I publish my link it shows only http:// mywebsite.com/abc/?id=fasfsa
It doesn't show the variable 'id2'. Anyone knows a method?
It doesnt show the variable id2 because it takes only his variables (url,linkname,image). I want to put all the link on the variable url .
How to get address in the browser using php.
I want a way in which I can fetch the url value that is present in the browser. If I manually add a #tag to the existing url then I want to retrieve that as well.
I have used this code till now, but I want to retrieve https or http whatever value is in the browser.
Also this is my url:
http://example.com/xyz/?p=65
but suppose I build up the 2nd url manually then I would like to retrieve that as well
http://example.com/xyz/?p=65#fsgsg
$Path=$_SERVER['REQUEST_URI'];
echo $URI= 'http://'.$_SERVER['SERVER_NAME'].$Path;
The part behind the # is not delivered to the browser. You could however run a tiny javascript that sends you that information since it is available to the DOM (But do you really want that?) via the window object.
For getting has parameter,use below --
$url = 'http://amitbera.com/path?arg=value#anchor';
print_r(parse_url($url));
echo parse_url($url, PHP_URL_PATH);
More details in http://www.php.net/manual/en/function.parse-url.php
Also,For gettting arg value use $_SERVER['QUERY_STRING']
Your only option is to handle that parameter in javascript because the # (hash) part wont get sent to the backend side, You can just detect click of the target element in JS and then glue the # part as a parameter like '&hashValue=fsgsg'.
I hope that helps You in some way.
I m in a situation where i am redirecting user to another page with following jQuery code
window.location = "/#/customer/email?isEmail=true&eid=1&template=2";
i have some url re-writing , and so complete url becomes is
https://demo.qa.com/#/customer/email?isEmail=true&eid=1&template=2
but in PHP when i try to get full page url using this
echo $_SERVER['REQUEST_URI'];
it just gives me this
/
i just want to get variable IsEmail
$_GET['IsEmail']
value in PHP page,
I think the
#
in between the URL is creating the problem, is there any way to get it, please advise..
The fragment is never sent to the server, so if you want access to the query parameters you need to bring them forward:
https://demo.qa.com/?isEmail=true&eid=1&template=2#/customer/email
^ ^
query fragment
The anchor fragment portion of the URL (anything after #) isn't sent to the server at all. It only lives client-side. The server has no knowledge of it, and therefore PHP has no knowledge of it.
If you want to do anything with the anchor fragment, you must do it client-side.
Below are the relevant lines of code:
update.js
$('#tablePlaceholder').load('updateTable.php');
updateTable.php
$path = $_SERVER['REQUEST_URI'];
Normally $_SERVER['REQUEST_URI'] returns the URL, however in this case, the URI at the moment of the request is technically the PHP file, so what is returned is updateTable.php instead of the actual URL. Is there an alternate command I can use to get the URL instead of URI? I have resorted to storing the URL in a session/global variable to retain access to the actual URL in the PHP file, but it seems there must be a better way, though I have not found it. Any tips would be most welcome!
I was looking at the documentation for the jQuery load() command:
http://api.jquery.com/load/
It looks like I might be able to pass the URL as a string via the data argument?
$_SERVER['REQUEST_URI'] is supposed to give path of current script relative to root and not the full url. If you want to get full url path, take a look at the same question on stackoverflow with the solution also being there
Getting the full URL of the current page (PHP)
In my php script, I have written code to pull out the url variables and to store them in an array
For eg: if my url is
www/viewgallery.php?cname=Colorado-Fall&pcaption=Light-On-Dunes
Then in my array 'path_info' I have
$path_info[base] = /
$path_info[query_var][cname] = Colorado-Fall
$path_info[query_var][pcaption] = Light-on-Dunes
etc
Now, How can I use this array to make clean urls in my php code?
If I try to write the link as
<a href = viewgallery.php/$path_info[query_var][cname]/$path_info[query_var][pcaption]></a>
it won't take me to the requested page.
Ultimately, I want the url in my address bar to look as
www/viewgallery.php/Colorado-Fall/Light-On-Dunes
How can I make this link work with my php script?
I know I can do this with .htaccess but is it possible to do it just with my php script using my array variables?
This should work:
echo "<a href='viewgallery.php/{$path_info[query_var][cname]}/{$path_info[query_var][pcaption]}'></a>";
In your link you have written it as html. You should write it as php
and also remember to use quote marks on the a tag