Latox
Latox

Reputation: 4705

Password protected page, how to access it with PHP?

Say I have a page which is password protected with cPanel's directory password type of thing (htaccess), how could I access this page using PHP? So the php script would:

  1. Go to the password protected URL
  2. Enter the username
  3. Enter the password
  4. Return true if it worked, false if it didnt

Any help would be greatly appreciated.

Upvotes: 0

Views: 1085

Answers (1)

Jason McCreary
Jason McCreary

Reputation: 73031

Check out cURL.

You can set the connection options for CURLOPT_HTTPAUTH and pass the credentials. There's actually a user comment containing code that should help you get started with Basic Auth.

Upvotes: 2

Related Questions