How to get php url with no parameters [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have big problem. I have some code like :
This is in my folder "country"
if($_GET[''] == 'England') {
echo 'test';
}
Is that impossible to left empty get parameter? to get url like : link.com/country/England

You can do the following: example.com/country/?England, and check if the England key exists:
if(isset($_GET['England'])) {
// Do stuff
}
Without the ? characters, it's a bit more difficult and require to rewrite URL with [mod_rewrite][1] if you're using Apache web server for example

You are looking for url rewriting: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

Related

How to make nicer PHP urls [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I would like to replace my links appeared in my page's adressbar.
Now the links have this format: http://mypage.com/index.php?page=contact
And I want this format: mypage.com/contact
How to do that?
(No links please, I need example.)
Update:
This is one possible solution that worked:
RewriteEngine on
RewriteRule ^([^/.]+)?$ index2.php?page=$1 [L]
Take a look at htaccess and mod_rewrite.
You asked for no links, so I'll let you Google them yourself.
Once you have a chosen path, try it out and if you can't get it working come back with examples of what you've tried and in what way they didn't work.

Do something if "?something" is present at the end of a URL [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to make it so that if there is a ?no at the end of a url, then something does not happen. But, if there is nothing at the end of the url, then something does happen. How can I do this?
use
if (!isset($_REQUEST['no'])) {
//something happen
} else {
//do nothing
}

GPS Location Coordinaties in PHP [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How can I write a code that gets the current location coordinates (LLA) in my web browser using PHP .
Is it possible by using GPS via HTTP or something like that ?
please help
Thanks
You will need to use the brower's geolocation API, for example as shown here.
Then, you simply pass the parameters to a PHP script using whatever method you like, a form, or a jQuery post.

How to create a URL where the query parameters are saved to some form of DB [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am looking to create a simple url where I can add URL querys to it and then have these saved to a database.
This would be the format that i'm looking for
example.com?name=value1&email=value2
Could anybody help ?
Get the values on the script from $_GET, then put them in your database using PDO or MySQLi. I don't know your database structure so I can't really help any further:
// In index.php
echo $_GET["name"];
echo $_GET["email"];
// Put them in your database

Grab part of an URL in PHP [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have this link viewdocument.php?a=http%3A%2F%2Fwww.iesalfonsox.com%2Fimages%2FLIBROS_ESO_13-14.pdf in (for example) index.php and I want to put only the URL of the document of the link.
Example:
Link: http://www.myweb.com/viewdocument.php?a=some.pdf
On the HTML: You're viewing "Some.pdf".
Do you understand? Convert "viewdocument.php?a=some.pdf" to "some.pdf".
If this is the current URL being accessed on your site, Php provide globals and you can access it using the $_GET variable:
so for your example you will use this:
$file = $_GET['a']; // will return some.pdf
The other case will be for parsing a url from a string, for which php provides a function:
parse_url();
Follow the link to see examples

Categories