1

Im am very new to PHP (although i am programmed in object-c programming for iOS and this is why i need this). I need to get the username and password out of a post url and into variables for example this: http://url.com/phpFile.php?username=TheUsernameToGetOut&password=ThePasswordToGetOut Many Thanks

1
  • Do you mean a POST or a GET request? PHP handles those differently. Your link suggest you mean a GET request, but you're saying POST... so it's confusing. Commented Apr 29, 2012 at 12:54

4 Answers 4

1

You can find the parameters sent in the url (Get parameters) through the super global array $_GET. example:

$username = $_GET['username'];
$password = $_GET['password'];

$_GET from php manual

If the parameters were sent instead via a post (posting a form) then they will be available through the $_POST super global array. example:

$username = $_POST['username'];
$password = $_POST['password'];

$_POST from php manual

Sign up to request clarification or add additional context in comments.

Comments

1

You should never use a query string to pass such a sensitive information like username and password.

So, there should be just http://example.com/phpFile.php accessed with POST method and thus you will get your variables vis

$username = $_POST['username'];
$password = $_POST['password'];

Comments

0

All the GET parameters will be stored in $_GET global array and all POST parameters will be stored in $_POST

$username = $_POST['username']
$password = $_POST['password']

Comments

0

You need to get the username and password from url. So why are you using $_POST It will not work. Use $_GET or $_REQUEST

$username = $_POST['username'];
$password = $_POST['password'];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.