I have created dynamic url's like this:
http://www.example.com/index.php?page=test
But, if I send values via GET, I cannot get the values because the URL is structured like this:
http://www.example.com/index.php?page=test?value=1
How could I get the values without using POST? This is because I use a third-party app and they only support GET.
If you create your dynamic url's like
http://www.example.com/index.php?page=test&
then you will get
http://www.example.com/index.php?page=test&?value=1
which I believe you should be able to work with. You will then just have to look for the first parameter after your initial ? as $_GET['?value'] I believe
I hope I understood the question, but you could assign a full list of variables separated with & except for the first one.
$page = 'test&value=1';
and then assign it to your url.
Related
What is the code in PHP
How to pass data from a URL using a ? is straight forward.
http://localhost/raw.php?topic=news
What is needed is to pass data like domaintools.com does just with the data after the /
news.com/football
news.com/politics
A. domaintools.com/stackoverflow.com
B. gives the whois on file (from domaintools database) and even changing the url to fit there system
C. https://whois.domaintools.com/stackoverflow.com
I have googled many permutations of keywords, php code passing via url not a using a ? and many variations of the such with other terms like $path etc
My guess is we missing something easy and/or we just don't know the right question to ask.
Using "?" is called GET parameter, you can use POST parameters to post data to an endpoint
From what I understand it is possible to get query strings and clean up the url afterwards.
I basically want to send a user a link containing many types of data to build up a special page for them and afterwards clean up the url to hide the mess. I would mainly use the parameters to load certain products etc.
What would be the best way going about this? And is this even possible?
Thank you.
My thought is use two functions/links instead for this. First function/link will be that user will click and store those values in a session and transfer it to other neat URL .
I'm using PHP and I'd like to create an if statement that does something if the user came to the current page from the home page. So far, I've been using this code:
if(!in_array($_SERVER['HTTP_REFERER'], $validHomes){
//do something}
The array $validHomes contains a couple different variations of index.php (without .php, without www.)
This has been working fine but now I'd like the home page to have a GET variable sometimes which will have different values: www.example.com/index?var=5. $_SERVER['HTTP_REFERER'] treats URLs with GET variables that have different values as different from each other so I'm wondering if anyone has a suggestion for how to get around this? How can I trigger the if statement for a wide range of index URLs that contain GET variables with different values?
Thanks a lot for any help.
It would be better to add a GET parameter from your home page links and check for that parameter instead. This would be far simpler and more reliable.
Another option would be to use stristr($_SERVER['HTTP_REFERER'], 'index');
Though Matt's answer is indeed more reliable.
I am very new to programming and need a little help with getting data from a website and passing it into my PHP script.
The website is http://www.birthdatabase.com/.
I would like to plug in a name (First and Last) and retrieve the result. I know you can query the site by passing the name in the URL, but I am having problems scraping the results.
http://www.birthdatabase.com/cgi-bin/query.pl?textfield=FIRST&textfield2=LAST&age=&affid=
I am using the file_get_contents($URL) function to get the page but need help after that. Specifically, I would like to scrape only the results from a certain state if there are multiple results for that name.
Thanks for your help.
Read about POST method and its array ($_POST) ---> reference.
Similarly, there is GET method as well.
Why dont you see POST AND GET method?
I am trying to get an HTML/PHP script to interpret data sent after the ? in a url. I've seen sites that do this, YouTube being one of them. I thought this was called Post Data (not sure if it is), I've been searching for a few days, and I can find is the PHP $_POST[''] with some HTML forms reading the data from a textbox, but I would like to read directly from the url, EX. www.example.com?ver=1
How would I go about doing this?
What you're looking for is called a query string. You can find that data in $_GET.
print_r($_GET);
If you need access to the raw data (and you probably don't, unless you need multiples for some variable names), check $_SERVER['QUERY_STRING'].
You can't do that in HTML pages. In PHP pages, you can read (and process) the parameters using the $_GET array. This array contains all the things after which come after ? in the URL. Suppose we have a URL like
page.php?a=b&c=d
Then we can access a and c parameters by $_GET['a'] and $_GET['b']. There is also $_POST which works a bit different. You can google it to find out more.