Can someone help?

I have a php script but I want it to run only if someone have a username and password that would be included in a config.php file.

So let's say I have the script named horoscope.php and the database.txt file with 100 pre defined serials and usernames. In order for the horoscope.php file to run it must find the config.php file and the username,password,(i.e user1,pass1). Those must also be in the database.txt file. This database.txt will have i.e 100 usernames and passwords:

user1,pass1
user2,pass2
user3,pass3
user4,pass4

If the username and password in the config.php don't match with one of the 100s in the database.txt then the horoscope.php file must not run.

Thanks again in advance for your time and help.

James

    Hm,

    What is your actual problem? You do not know how to retrieve the names etc from the file? You do not know how to compare them to a set of user/pass which has been ubsmitted? You do not know how to build a form? You do not know how to run/not run a script?

    You need to be more exact. Unless you need someone to build the script for you. Then you'd have to go to a web-building comp, I suppose.

    Anyway. In short:

    • Form asks for username / password
    • Form is submitted
    • Read values from file
    • comepare submitted values against file values
    • if match, then run script. Else don't.

    J.

      Well I have this code:

      // horoscope.php
      <?php
      include_once('config.php');
      include_once('database.php');

      for($i=0; $i < count($data); $i++) {
      if($username == $data[$i]['username']) && ($password == $data[$i]['password'])) {
      $authorised = 'true';
      }
      }
      if(!isset($authorised)) {
      exit('You are not authorised to run this script.');
      }

      // the rest of the horoscope.php script goes here

      ?>

      // config.php
      <?php
      $username = 'bob';
      $password = '12345';
      ?>

      // database.php
      <?php
      $data[0]['username'] = 'bob';
      $data[0]['password'] = '12345';

      $data[1]['username'] = 'joe';
      $data[1]['password'] = '67890';

      $data[2]['username'] = 'jill';
      $data[2]['password'] = 'abcde';

      $data[2]['username'] = 'jane';
      $data[2]['password'] = 'fghij';
      ?>

      I have those scripts up on my server and running ok.

      Now I want to have the database.php file on another server. So If I give a horoscope script to my users and someone after doesn't want to pay the next month or next year subscription then remotely from my server to delete the password and user name from the database.php so that he can't run the script.

      So How can I include the database.php file from another server?
      Because if I use

      include_once('http://mydomain.com/database.php'); it doesn't work.

      Is there a way to do that?

      Thanks for your help and time in advance

      James

        If he has the script on his server, he can ALWAYS run the scripot. All he has to do is download it, and remove the protection.
        Keep the script on your server too, and let them log in through your server.

        J.

          The scripts that my users will get they will be locked by a codelock script. Is it possible to override this lock?
          And what is the scripot anyway?

          regards

          James

            Write a Reply...