Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What you could do is use a php class that requires you to log in or sign up to your Website. You can find plenty from a quick <a href="http://google.com/search?q=php+log+in+sign+up+classes" rel="nofollow">Google</a>.</p> <p>Then, you should make an API on your Website that only sends data back if you're authenticated. Here's an example that would read data from a MySQL database:</p> <pre><code>&lt;?php require_once $_SERVER["DOCUMENT_ROOT"] . "/includes/accounts.class.php"; //Change this to the path to your authentication script header("Content-Type: application/json"); //Important if you're using json $account = new Accounts(); //A fictional Accounts class is opened $json = array(); if (!$account-&gt;authenticated or $account-&gt;rights != "administrator") { //Ask the class if the user is not an admin $json = array( "error" =&gt; "Not an administrator" ); } else { $query = mysqli_query($link, "SELECT * FROM example"); //Assuming you use mysqli and there's a table called example if (!$query or mysqli_num_rows($query) &lt; 1) { $json = array( "error" =&gt; "Query returned no results" ); } else { while ($row = mysqli_fetch_array($query)) { //Read the data from the table $json[] = $row; } } } echo json_encode($json); //Send the data as a json string </code></pre> <p>Remember that the above code is only an example of how you would do this sort of script. You'll need to modify it to work with the class and database you are using. Now you can make your own program for your own internal use that logs in to and queries data from your API. This could be a Website running on an internal server, a Windows program or a smartphone app. All it would need to do is fill in the form on the log in Webpage, then send a HTTP request to the script above and decode the json result.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload