Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7962147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:15:09+00:00 2026-06-04T05:15:09+00:00

This is my first php script. I actually code in vb.net.. I am making

  • 0

This is my first php script. I actually code in vb.net.. I am making this licensing system for .net applications. This licensing system has a manager which the admin can easily control and view. Also Iam making a class library to login and register for the same. I have succeeded in doing so using only vb.net code but as the credentials need to be stored inside the application there always is a threat. Using php this problem can be overcomed somewhat :tongue: . So I decided to make the login + register system using this kinda php scripts. I am using a only admin read,write text file instead of a mysql database ( Easily maneagable for all hosting services ). So, I have come up with this following piece of code and I need some help in the confirming the login part.
The text file is like this :

username password hwid lastdate membershiptype

All separated by ‘space’ and one account per line.
I hope I have given enough information, If extra information is needed, I will give it.

<?php
$user = addslashes($_GET['username']);
$pass = addslashes($_GET['password']);

  $username = "theusername";  
  $password = "thepassword";  
  $url = "mywebsite.com/file.txt";
  $hostname= "ftp://$username:$password@$url";  
  $contents = file_get_contents($hostname); 
// That gives me the txt file which can only be read and written by the admin
if (strpos($contents,$user) !== false) {
   // Need code here to check if the adjacent word and the $pass are same to establish a successfull login
} else {
 echo "Username does not exist, please register"
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T05:15:10+00:00Added an answer on June 4, 2026 at 5:15 am

    Here try this, hope it helps:

    file.txt would need tobe in this format, values seperated by :, spaces are not a good way to seperate values.

    username:password:hwid:lastdate:membershiptype
    

    The PHP bit:

    <?php
    $user = $_GET['username'];
    $pass = $_GET['password'];
    
    if(check_auth(get_auth(),$user,$pass)==true){
        echo 'Yes';
    }else{
        echo 'No';
    }
    
    /**
     * This function will grab the text file and create a user array
     * 
     * @return array(0=>username,1=>password)
     */
    function get_auth(){
        $username = "theusername";
        $password = "thepassword";
        $url = "mywebsite.com/file.txt";
        $location = "ftp://$username:$password@$url";
    
        $users = file($location);
        function split_auth(&$value){
            $value = explode(':',$value);
        }
        array_walk($users,'split_auth');
        return $users;
    }
    
    /**
     * This Function will check the username and password
     *  against the users array
     *
     * @param array $users
     * @param string $username
     * @param string $password
     * @return bool (true|false)
     */
    function check_auth($users,$username,$password){
        foreach($users as $user){
            if($user[0]==$username && $user[1]==$password){
                return true;
            }
        }
        return false;
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

when I run this code for the first time <?php session_start(); echo SID; ?>
I found this on a website, css_loader.php <?php // First of all send css
This is my first question :). Im writing a little twitter app in PHP
Hello everyone I am a newbie to php and this is my first ever
This is user.php: include(databse.php);//retrieving successfully first name and lastname from databse file into user.php
I downloaded a program implemented in Java (in this case, http://julian.togelius.com/mariocompetition2009/index.php ). I first
I want to implement a two-pass cache system: The first pass generates a PHP
I am following this tutorial step by step http://code.google.com/apis/maps/articles/phpsqlajax.html . Actually I copy pasted
I have a php script that is triggered from my app. This script uses
This first bit works: $my_id = 617; $post_id_7 = get_post($my_id); $title = $post_id_7->post_excerpt; echo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.