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 .
Related
id like to get the url of an website, which an website is automatically referring to.
For example:
When i browse the link "www.example.de" it refers me automatically to "www.example.de/example123/example.php" (This one id like to get)
Unfortunetaly it is not possible to get the second link but using the first link.
Greeting,
Geigerkind
Try this out:
$url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
(Sorry haven't got a PHP up to test on)
I have this link:
www.something.com/index.php?page=teams
I then have this link:
Profile
I want to achieve is this link:
www.something.com/index.php?page=teams&profile=5
But I get this instead:
www.something.com?profile=5
The tricky part is that I can't just write the whole "path" like this:
Profile
Because it isn't always on the page 'teams'.
It might be a pretty stupid question, but i can't really figure it out.
You must include the page=teams parameter in the href.
Instead of
Profile
Something like
Profile
If that link is static you must need to update the html file.
But if page=anyvalue then you must generate the href link dynamically in your php code
for example:
Where $page is the current page, e.g $page="teams"
Well, you can just add it to the query string using http_build_query:
$newQueryString = http_build_query(['profile' => 5] + $_GET);
And then output it to your link:
Profile
Try something like this:
echo '<a href="'.{$_SERVER['SCRIPT_NAME']}.{$_SERVER['QUERY_STRING']}
.'&profile=5">Profile</a>
This makes use of $_SERVER to get the current page name (SCRIPT_NAME) and the existing query string (QUERY_STRING), and then appends "&profile=5" onto the end.
Well i have sort of fixed it.... i created a session called page, so i can access it everywhere. The thing is i can't get the variable $_GET['page'] because it's inside a included file called search.php, therefore i created the session.. But thanks for you suggestions guys!
I´ve got an url like this www.example.com/v=12345. This will go to my index.php site on my webserver and the variable 'v' is used to do some javascript stuff, which works fine.
Now i want to link to the document 'newsite.php" like this or similar: www.example.com/newsite.php/v=12345. This does not work since the css does not work anymore and i don't know why.. If i do it like www.example.com/newsite.phpv=12345 , the variable is read correctly but it opens the index.php again.. How can i do this correctly?
Thanks guys!
You should pass php variable in url as parameter like this:
www.example.com?v=12345
and in your php just get this value by:
$_GET['v']
It should solve your problems :)
Variables need the seperator ? between url and variable. And if you have more Variables, the variables are seperated with a &
Example:
www.domain.com/?v=123
www.domain.com/script.php?v=123
www.domain.com/?v=123&y=456
And every variable will be available via $_GET[]
$_GET['v']
$_GET['y']
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
At the moment a chuck of my site is running off using GETs to direct to a profile or a page. But what if you go to someone's profile page (so that's one GET) and you then click a sub tab on their profile which uses another GET, can you do this:
http://example.com/something.php?xyz=4example=6
I have seen facebook do this however I'm not sure where to look.
An alternate to this would be Javascript however I would rather do it with PHP if possible.
That should be
example.com/something.php?xyz=4&example=6
Note the ampersand '&' between the get vars.
To access the vars in php use
$xyz = $_GET['xyz'];
$example = $_GET['example'];
I am not sure ur exact question but in general if you want to pass values to a page through url u should do e.g.
http://example.com/page1.php?var1=val1&var2=val2....
Please note that each new variable after the first one has "&" before it. This tells the server that a new variable is expected, and the first variable has "?" before it, which tells the server to expect variables.
In the php page you can get the values of all the passed variables like
<?php
$_GET['var1']
$_GET['var2']
.
.
.
?>
and further user the values however you like. Note that you can not change a value in $_GET['var1']. If you want to change a value. First assign this value to a variable then further process. e.g
<?php
$var1 = $_GET['var1'];
$var1++;
?>