Wednesday, December 28, 2016

Linux Command Line Tutorial For Beginners 24 - Basic Group Management (g...

Linux Command Line Tutorial For Beginners 23 - userdel command (Removing...



USERDEL(8)                                   System Management Commands                                   USERDEL(8)



NAME
       userdel - delete a user account and related files

SYNOPSIS
       userdel [options] LOGIN

DESCRIPTION
       userdel is a low level utility for removing users. On Debian, administrators should usually use deluser(8)
       instead.

       The userdel command modifies the system account files, deleting all entries that refer to the user name
       LOGIN. The named user must exist.

OPTIONS
       The options which apply to the userdel command are:

       -f, --force
           This option forces the removal of the user account, even if the user is still logged in. It also forces
           userdel to remove the user's home directory and mail spool, even if another user uses the same home
           directory or if the mail spool is not owned by the specified user. If USERGROUPS_ENAB is defined to yes
           in /etc/login.defs and if a group exists with the same name as the deleted user, then this group will be
           removed, even if it is still the primary group of another user.

           Note: This option is dangerous and may leave your system in an inconsistent state.

       -h, --help
           Display help message and exit.

       -r, --remove
           Files in the user's home directory will be removed along with the home directory itself and the user's
           mail spool. Files located in other file systems will have to be searched for and deleted manually.

           The mail spool is defined by the MAIL_DIR variable in the login.defs file.

       -R, --root CHROOT_DIR
           Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory.

       -Z, --selinux-user
           Remove any SELinux user mapping for the user's login.

CONFIGURATION
       The following configuration variables in /etc/login.defs change the behavior of this tool:

       MAIL_DIR (string)
           The mail spool directory. This is needed to manipulate the mailbox when its corresponding user account is
           modified or deleted. If not specified, a compile-time default is used.

       MAIL_FILE (string)
           Defines the location of the users mail spool files relatively to their home directory.

       The MAIL_DIR and MAIL_FILE variables are used by useradd, usermod, and userdel to create, move, or delete the
       user's mail spool.

       MAX_MEMBERS_PER_GROUP (number)
           Maximum members per group entry. When the maximum is reached, a new group entry (line) is started in
           /etc/group (with the same name, same password, and same GID).

           The default value is 0, meaning that there are no limits in the number of members in a group.

           This feature (split group) permits to limit the length of lines in the group file. This is useful to make
           sure that lines for NIS groups are not larger than 1024 characters.

           If you need to enforce such limit, you can use 25.

           Note: split groups may not be supported by all tools (even in the Shadow toolsuite). You should not use
           this variable unless you really need it.

       USERDEL_CMD (string)
           If defined, this command is run when removing a user. It should remove any at/cron/print jobs etc. owned
           by the user to be removed (passed as the first argument).

           The return code of the script is not taken into account.

           Here is an example script, which removes the user's cron, at and print jobs:

               #! /bin/sh

               # Check for the required argument.
               if [ $# != 1 ]; then
                    echo "Usage: $0 username"
                    exit 1
               fi

               # Remove cron jobs.
               crontab -r -u $1

               # Remove at jobs.
               # Note that it will remove any jobs owned by the same UID,
               # even if it was shared by a different username.
               AT_SPOOL_DIR=/var/spool/cron/atjobs
               find $AT_SPOOL_DIR -name "[^.]*" -type f -user $1 -delete \;

               # Remove print jobs.
               lprm $1

               # All done.
               exit 0



       USERGROUPS_ENAB (boolean)
           If set to yes, userdel will remove the user's group if it contains no more members, and useradd will
           create by default a group with the name of the user.

FILES
       /etc/group
           Group account information.

       /etc/login.defs
           Shadow password suite configuration.

       /etc/passwd
           User account information.

       /etc/shadow
           Secure user account information.

EXIT VALUES
       The userdel command exits with the following values:

       0
           success

       1
           can't update password file

       2
           invalid command syntax

       6
           specified user doesn't exist

       8
           user currently logged in

       10
           can't update group file

       12
           can't remove home directory

CAVEATS
       userdel will not allow you to remove an account if there are running processes which belong to this account.
       In that case, you may have to kill those processes or lock the user's password or account and remove the
       account later. The -f option can force the deletion of this account.

       You should manually check all file systems to ensure that no files remain owned by this user.

       You may not remove any NIS attributes on a NIS client. This must be performed on the NIS server.

       If USERGROUPS_ENAB is defined to yes in /etc/login.defs, userdel will delete the group with the same name as
       the user. To avoid inconsistencies in the passwd and group databases, userdel will check that this group is
       not used as a primary group for another user, and will just warn without deleting the group otherwise. The -f
       option can force the deletion of this group.

SEE ALSO
       chfn(1), chsh(1), passwd(1), login.defs(5), gpasswd(8), groupadd(8), groupdel(8), groupmod(8), useradd(8),
       usermod(8).



shadow-utils 4.1.5.1                                 02/17/2014                                           USERDEL(8)

Linux Command Line Tutorial For Beginners 22 - useradd command (Creatin...

USERADD(8)                                   System Management Commands                                   USERADD(8)



NAME
       useradd - create a new user or update default new user information

SYNOPSIS
       useradd [options] LOGIN

       useradd -D

       useradd -D [options]

DESCRIPTION
       useradd is a low level utility for adding users. On Debian, administrators should usually use adduser(8)
       instead.

       When invoked without the -D option, the useradd command creates a new user account using the values specified
       on the command line plus the default values from the system. Depending on command line options, the useradd
       command will update system files and may also create the new user's home directory and copy initial files.

       By default, a group will also be created for the new user (see -g, -N, -U, and USERGROUPS_ENAB).

OPTIONS
       The options which apply to the useradd command are:

       -b, --base-dir BASE_DIR
           The default base directory for the system if -dHOME_DIR is not specified.  BASE_DIR is concatenated with
           the account name to define the home directory. If the -m option is not used, BASE_DIR must exist.

           If this option is not specified, useradd will use the base directory specified by the HOME variable in
           /etc/default/useradd, or /home by default.

       -c, --comment COMMENT
           Any text string. It is generally a short description of the login, and is currently used as the field for
           the user's full name.

       -d, --home HOME_DIR
           The new user will be created using HOME_DIR as the value for the user's login directory. The default is
           to append the LOGIN name to BASE_DIR and use that as the login directory name. The directory HOME_DIR
           does not have to exist but will not be created if it is missing.

       -D, --defaults
           See below, the subsection "Changing the default values".

       -e, --expiredate EXPIRE_DATE
           The date on which the user account will be disabled. The date is specified in the format YYYY-MM-DD.

           If not specified, useradd will use the default expiry date specified by the EXPIRE variable in
           /etc/default/useradd, or an empty string (no expiry) by default.

       -f, --inactive INACTIVE
           The number of days after a password expires until the account is permanently disabled. A value of 0
           disables the account as soon as the password has expired, and a value of -1 disables the feature.

           If not specified, useradd will use the default inactivity period specified by the INACTIVE variable in
           /etc/default/useradd, or -1 by default.

       -g, --gid GROUP
           The group name or number of the user's initial login group. The group name must exist. A group number
           must refer to an already existing group.

           If not specified, the behavior of useradd will depend on the USERGROUPS_ENAB variable in /etc/login.defs.
           If this variable is set to yes (or -U/--user-group is specified on the command line), a group will be
           created for the user, with the same name as her loginname. If the variable is set to no (or
           -N/--no-user-group is specified on the command line), useradd will set the primary group of the new user
           to the value specified by the GROUP variable in /etc/default/useradd, or 100 by default.

       -G, --groups GROUP1[,GROUP2,...[,GROUPN]]]
           A list of supplementary groups which the user is also a member of. Each group is separated from the next
           by a comma, with no intervening whitespace. The groups are subject to the same restrictions as the group
           given with the -g option. The default is for the user to belong only to the initial group.

       -h, --help
           Display help message and exit.

       -k, --skel SKEL_DIR
           The skeleton directory, which contains files and directories to be copied in the user's home directory,
           when the home directory is created by useradd.

           This option is only valid if the -m (or --create-home) option is specified.

           If this option is not set, the skeleton directory is defined by the SKEL variable in /etc/default/useradd
           or, by default, /etc/skel.

           If possible, the ACLs and extended attributes are copied.

       -K, --key KEY=VALUE
           Overrides /etc/login.defs defaults (UID_MIN, UID_MAX, UMASK, PASS_MAX_DAYS and others).

           Example: -K PASS_MAX_DAYS=-1 can be used when creating system account to turn off password ageing, even
           though system account has no password at all. Multiple -K options can be specified, e.g.: -K
           UID_MIN=100-K UID_MAX=499

       -l, --no-log-init
           Do not add the user to the lastlog and faillog databases.

           By default, the user's entries in the lastlog and faillog databases are resetted to avoid reusing the
           entry from a previously deleted user.

           For the compatibility with previous Debian's useradd, the -O option is also supported.

       -m, --create-home
           Create the user's home directory if it does not exist. The files and directories contained in the
           skeleton directory (which can be defined with the -k option) will be copied to the home directory.

           By default, if this option is not specified and CREATE_HOME is not enabled, no home directories are
           created.

       -M
           Do no create the user's home directory, even if the system wide setting from /etc/login.defs
           (CREATE_HOME) is set to yes.

       -N, --no-user-group
           Do not create a group with the same name as the user, but add the user to the group specified by the -g
           option or by the GROUP variable in /etc/default/useradd.

           The default behavior (if the -g, -N, and -U options are not specified) is defined by the USERGROUPS_ENAB
           variable in /etc/login.defs.

       -o, --non-unique
           Allow the creation of a user account with a duplicate (non-unique) UID.

           This option is only valid in combination with the -u option.

       -p, --password PASSWORD
           The encrypted password, as returned by crypt(3). The default is to disable the password.

           Note: This option is not recommended because the password (or encrypted password) will be visible by
           users listing the processes.

           You should make sure the password respects the system's password policy.

       -r, --system
           Create a system account.

           System users will be created with no aging information in /etc/shadow, and their numeric identifiers are
           chosen in the SYS_UID_MIN-SYS_UID_MAX range, defined in /etc/login.defs, instead of UID_MIN-UID_MAX (and
           their GID counterparts for the creation of groups).

           Note that useradd will not create a home directory for such an user, regardless of the default setting in
           /etc/login.defs (CREATE_HOME). You have to specify the -m options if you want a home directory for a
           system account to be created.

       -R, --root CHROOT_DIR
           Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory.

       -s, --shell SHELL
           The name of the user's login shell. The default is to leave this field blank, which causes the system to
           select the default login shell specified by the SHELL variable in /etc/default/useradd, or an empty
           string by default.

       -u, --uid UID
           The numerical value of the user's ID. This value must be unique, unless the -o option is used. The value
           must be non-negative. The default is to use the smallest ID value greater than or equal to UID_MIN and
           greater than every other user.

           See also the -r option and the UID_MAX description.

       -U, --user-group
           Create a group with the same name as the user, and add the user to this group.

           The default behavior (if the -g, -N, and -U options are not specified) is defined by the USERGROUPS_ENAB
           variable in /etc/login.defs.

       -Z, --selinux-user SEUSER
           The SELinux user for the user's login. The default is to leave this field blank, which causes the system
           to select the default SELinux user.

   Changing the default values
       When invoked with only the -D option, useradd will display the current default values. When invoked with -D
       plus other options, useradd will update the default values for the specified options. Valid default-changing
       options are:

       -b, --base-dir BASE_DIR
           The path prefix for a new user's home directory. The user's name will be affixed to the end of BASE_DIR
           to form the new user's home directory name, if the -d option is not used when creating a new account.

           This option sets the HOME variable in /etc/default/useradd.

       -e, --expiredate EXPIRE_DATE
           The date on which the user account is disabled.

           This option sets the EXPIRE variable in /etc/default/useradd.

       -f, --inactive INACTIVE
           The number of days after a password has expired before the account will be disabled.

           This option sets the INACTIVE variable in /etc/default/useradd.

       -g, --gid GROUP
           The group name or ID for a new user's initial group (when the -N/--no-user-group is used or when the
           USERGROUPS_ENAB variable is set to no in /etc/login.defs). The named group must exist, and a numerical
           group ID must have an existing entry.

           This option sets the GROUP variable in /etc/default/useradd.

       -s, --shell SHELL
           The name of a new user's login shell.

           This option sets the SHELL variable in /etc/default/useradd.

NOTES
       The system administrator is responsible for placing the default user files in the /etc/skel/ directory (or
       any other skeleton directory specified in /etc/default/useradd or on the command line).

CAVEATS
       You may not add a user to a NIS or LDAP group. This must be performed on the corresponding server.

       Similarly, if the username already exists in an external user database such as NIS or LDAP, useradd will deny
       the user account creation request.

       It is usually recommended to only use usernames that begin with a lower case letter or an underscore,
       followed by lower case letters, digits, underscores, or dashes. They can end with a dollar sign. In regular
       expression terms: [a-z_][a-z0-9_-]*[$]?

       On Debian, the only constraints are that usernames must neither start with a dash ('-') nor plus ('+') nor
       tilde ('~') nor contain a colon (':'), a comma (','), or a whitespace (space: ' ', end of line: '\n',
       tabulation: '\t', etc.). Note that using a slash ('/') may break the default algorithm for the definition of
       the user's home directory.

       Usernames may only be up to 32 characters long.

CONFIGURATION
       The following configuration variables in /etc/login.defs change the behavior of this tool:

       CREATE_HOME (boolean)
           Indicate if a home directory should be created by default for new users.

           This setting does not apply to system users, and can be overridden on the command line.

       GID_MAX (number), GID_MIN (number)
           Range of group IDs used for the creation of regular groups by useradd, groupadd, or newusers.

           The default value for GID_MIN (resp.  GID_MAX) is 1000 (resp. 60000).

       MAIL_DIR (string)
           The mail spool directory. This is needed to manipulate the mailbox when its corresponding user account is
           modified or deleted. If not specified, a compile-time default is used.

       MAIL_FILE (string)
           Defines the location of the users mail spool files relatively to their home directory.

       The MAIL_DIR and MAIL_FILE variables are used by useradd, usermod, and userdel to create, move, or delete the
       user's mail spool.

       MAX_MEMBERS_PER_GROUP (number)
           Maximum members per group entry. When the maximum is reached, a new group entry (line) is started in
           /etc/group (with the same name, same password, and same GID).

           The default value is 0, meaning that there are no limits in the number of members in a group.

           This feature (split group) permits to limit the length of lines in the group file. This is useful to make
           sure that lines for NIS groups are not larger than 1024 characters.

           If you need to enforce such limit, you can use 25.

           Note: split groups may not be supported by all tools (even in the Shadow toolsuite). You should not use
           this variable unless you really need it.

       PASS_MAX_DAYS (number)
           The maximum number of days a password may be used. If the password is older than this, a password change
           will be forced. If not specified, -1 will be assumed (which disables the restriction).

       PASS_MIN_DAYS (number)
           The minimum number of days allowed between password changes. Any password changes attempted sooner than
           this will be rejected. If not specified, -1 will be assumed (which disables the restriction).

       PASS_WARN_AGE (number)
           The number of days warning given before a password expires. A zero means warning is given only upon the
           day of expiration, a negative value means no warning is given. If not specified, no warning will be
           provided.

       SYS_GID_MAX (number), SYS_GID_MIN (number)
           Range of group IDs used for the creation of system groups by useradd, groupadd, or newusers.

           The default value for SYS_GID_MIN (resp.  SYS_GID_MAX) is 101 (resp.  GID_MIN-1).

       SYS_UID_MAX (number), SYS_UID_MIN (number)
           Range of user IDs used for the creation of system users by useradd or newusers.

           The default value for SYS_UID_MIN (resp.  SYS_UID_MAX) is 101 (resp.  UID_MIN-1).

       UID_MAX (number), UID_MIN (number)
           Range of user IDs used for the creation of regular users by useradd or newusers.

           The default value for UID_MIN (resp.  UID_MAX) is 1000 (resp. 60000).

       UMASK (number)
           The file mode creation mask is initialized to this value. If not specified, the mask will be initialized
           to 022.

           useradd and newusers use this mask to set the mode of the home directory they create

           It is also used by pam_umask as the default umask value.

       USERGROUPS_ENAB (boolean)
           If set to yes, userdel will remove the user's group if it contains no more members, and useradd will
           create by default a group with the name of the user.

FILES
       /etc/passwd
           User account information.

       /etc/shadow
           Secure user account information.

       /etc/group
           Group account information.

       /etc/gshadow
           Secure group account information.

       /etc/default/useradd
           Default values for account creation.

       /etc/skel/
           Directory containing default files.

       /etc/login.defs
           Shadow password suite configuration.

EXIT VALUES
       The useradd command exits with the following values:

       0
           success

       1
           can't update password file

       2
           invalid command syntax

       3
           invalid argument to option

       4
           UID already in use (and no -o)

       6
           specified group doesn't exist

       9
           username already in use

       10
           can't update group file

       12
           can't create home directory

       14
           can't update SELinux user mapping

SEE ALSO
       chfn(1), chsh(1), passwd(1), crypt(3), groupadd(8), groupdel(8), groupmod(8), login.defs(5), newusers(8),
       userdel(8), usermod(8).



shadow-utils 4.1.5.1                                 02/17/2014                                           USERADD(8)

Wednesday, December 21, 2016

Node.js Tutorial for Beginners 16 - Node Package Manager (npm)

Node.js Tutorial for Beginners 16 - Basic Routing with node



var fs = require('fs');
var http = require('http');

http.createServer(function (req, res) {
  console.log('requested url : ' + req.url);
  if (req.url === '/home' || req.url === '/') {
    res.writeHead(200, { 'Content-Type': 'text/html' });
    fs.createReadStream('index.html').pipe(res);
  } else if (req.url === '/api') {
    res.writeHead(200, { 'Content-Type': 'application/json' });
    var jsonObj = {
      name: 'max',
      surname: 'tesar',
      age: 26
    };
    res.end(JSON.stringify(jsonObj));
  } else if (req.url === '/about') {
    res.writeHead(200, { 'Content-Type': 'text/html' });
    fs.createReadStream('about.html').pipe(res);
  } else {    
    res.writeHead(404, { 'Content-Type': 'text/html' });
    fs.createReadStream('404.html').pipe(res);
  }

}).listen(3000);

// Console will print the message
console.log("server is running on http://127.0.0.1:3000/")

Node.js Tutorial for Beginners 15 - Using node.js for serving JSON Data



var fs = require('fs');
var http = require('http');


http.createServer(function (req, res) {
   // Send the HTTP header 
   // HTTP Status: 200 : OK
   // Content Type: text/html

   res.writeHead(200, {'Content-Type': 'application/json'}); 
   var jsonObj = {
     name : 'max',
     surname : 'tesar',
     age : 26
   }; 
 res.end(JSON.stringify(jsonObj));
}).listen(3000);

// Console will print the message
console.log("server is running on http://127.0.0.1:3000/")

Saturday, December 17, 2016

Node.js Tutorial for Beginners 14 - Using node.js for serving HTML page



var fs = require('fs');
var http = require('http');


http.createServer(function (req, res) {
   // Send the HTTP header 
   // HTTP Status: 200 : OK
   // Content Type: text/html

   res.writeHead(200, {'Content-Type': 'text/html'});   
   var readStream = fs.createReadStream('index.html', 'utf8');
   readStream.pipe(res);
}).listen(3000);

// Console will print the message
console.log("server is running on http://127.0.0.1:3000/")

Node.js Tutorial for Beginners 13 - pipes





var fs = require('fs');
var http = require('http');


http.createServer(function (req, res) {
   // Send the HTTP header 
   // HTTP Status: 200 : OK
   // Content Type: text/plain

   res.writeHead(200, {'Content-Type': 'text/plain'});   
   var readStream = fs.createReadStream('file.txt', 'utf8');
   readStream.pipe(res);
}).listen(3000);

// Console will print the message
console.log("server is running on http://127.0.0.1:3000/")

Friday, December 16, 2016

Node.js Tutorial for Beginners 12 - Basics of Streams - Writable Streams



var fs = require('fs');

var readStream = fs.createReadStream('file.txt');
readStream.setEncoding('utf8');
var writeStream = fs.createWriteStream('write_file.txt');

readStream.on('data', function(chunk) {
    console.log('------------------------------------------------------------');
    writeStream.write(chunk);
})

readStream.on('end', function(chunk) {

    console.log('--------------------End----------------------------------------');
})

Monday, December 12, 2016

Node.js Tutorial for Beginners 11 - Basics of Streams - Readable Stream





var fs = require('fs');

var readStream = fs.createReadStream('file.txt');
readStream.setEncoding('utf8');
var data = '';
readStream.on('data', function(chunk) {
    console.log('------------------------------------------------------------');
    data += chunk;
    //console.log(chunk);
})

readStream.on('end', function(chunk) {
    console.log(data);
    console.log('--------------------End----------------------------------------');
})

Sunday, December 4, 2016

Node.js Tutorial for Beginners 10 - Node.js Events and EventEmitter






var events = require('events');
var util = require('util');


var Students = function(name) {
    this.name = name;
}

util.inherits(Students, events.EventEmitter);

var max = new Students('max');

max.on('scored', function(marks) {
   console.log(max.name + ' scores '+ marks+ ' marks');
})

max.emit('scored', 95);

var tom = new Students('tom');

tom.on('scored', function(marks) {
   console.log(tom.name + ' scores '+ marks+ ' marks');
})

tom.emit('scored', 60);

Thursday, September 1, 2016

Node.js Tutorial for Beginners 2 - How to Install Node.js with NPM on Wi...

In this video we will see How to Download , install and setup a node.js development environment on Windows.

Installation Steps



1. Download the Node.js Windows installer from the Nodes.js web site (https://nodejs.org).

2 Run the installer (the .msi file you downloaded in the previous step.)

3. Follow the prompts in the installer.

4. Restart your computer. You may not be able to run Node.js until you restart your computer.



To test Node.js

1. Open command promt and type "node -v" which will print the virsion of the node installed.

2. Also give the command "npm -v" to check the npm version.

3. Now Type "node" which will give you the node console.

4. console.log("Hello, World!"); to print hello world.



Saturday, February 27, 2016

How to Convert a Website into Android Application using Android Studio

















http://easyonlineconverter.com/



Searches related to How to Convert a Website into Android Application

convert website to web application

convert website to android app

convert website to android app online free

convert website to android app tutorial

convert wordpress website to android app

convert html5 to android app

software to convert website to android app

convert website to mobile app free

Sunday, February 21, 2016

MongoDB Tutorial for Beginners 7 - Query Document - AND OR Conditions



MongoDB Tutorial for Beginners 7 - Query Document - AND OR Conditions













$and   MongoDB

$or   MongoDB

Searches related to MongoDB - AND/ OR Conditions

mongodb multiple conditions

mongodb find conditions

mongodb query conditions

mongodb match multiple conditions

cakephp mongodb find conditions

mongodb query two conditions

mongodb $and

mongodb find multiple conditions

MongoDB Tutorial for Beginners 6 - Query Document















MongoDB,Database,Open Source database,NoSql,Installing MongoDB,MongoDB Tutorial for Beginners,starting mongodb linux,install mongodb on linux,Mongodb,overview,Advantages,Environment,Data Modelling,Create Database,Drop Database,Create Collection,Drop Collection,Data Types,Insert Document,Query Document,Update Document,Delete Document,Records,Replication,Sharding,Create Backup,Deployment,Relationships,Database References,Covered Queries,Analyzing Queries

Find or Query Data with the mongo Shell

db.collection.find()

MongoDB - Covered Queries

Learn MongoDB in simple and easy steps using this beginner's tutorial

Searches related to MongoDB - Query Document

mongodb find like

mongodb query java

mongodb find in array

mongodb query subdocument

mongodb query array

mongodb select fields

mongodb elemmatc

Thursday, January 7, 2016

Android MySQL Database Tutorial 2 - Android Login with PHP MySQL







package com.example.programmingknowledge.mysqldemo;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;


public class MainActivity extends ActionBarActivity {
    EditText UsernameEt, PasswordEt;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        UsernameEt = (EditText)findViewById(R.id.etUserName);
        PasswordEt = (EditText)findViewById(R.id.etPassword);
    }

public void OnLogin(View view) {
    String username = UsernameEt.getText().toString();
    String password = PasswordEt.getText().toString();
    String type = "login";
    BackgroundWorker backgroundWorker = new BackgroundWorker(this);
    backgroundWorker.execute(type, username, password);
}

}




package com.example.programmingknowledge.mysqldemo;

import android.app.AlertDialog;
import android.content.Context;
import android.os.AsyncTask;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;

/**
 * Created by ProgrammingKnowledge on 1/5/2016.
 */
public class BackgroundWorker extends AsyncTask<String,Void,String> {
    Context context;
    AlertDialog alertDialog;
    BackgroundWorker (Context ctx) {
        context = ctx;
    }
    @Override
    protected String doInBackground(String... params) {
        String type = params[0];
        String login_url = "http://192.168.1.6/login.php";
        if(type.equals("login")) {
            try {
                String user_name = params[1];
                String password = params[2];
                URL url = new URL(login_url);
                HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
                httpURLConnection.setRequestMethod("POST");
                httpURLConnection.setDoOutput(true);
                httpURLConnection.setDoInput(true);
                OutputStream outputStream = httpURLConnection.getOutputStream();
                BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
                String post_data = URLEncoder.encode("user_name","UTF-8")+"="+URLEncoder.encode(user_name,"UTF-8")+"&"
                        +URLEncoder.encode("password","UTF-8")+"="+URLEncoder.encode(password,"UTF-8");
                bufferedWriter.write(post_data);
                bufferedWriter.flush();
                bufferedWriter.close();
                outputStream.close();
                InputStream inputStream = httpURLConnection.getInputStream();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"iso-8859-1"));
                String result="";
                String line="";
                while((line = bufferedReader.readLine())!= null) {
                    result += line;
                }
                bufferedReader.close();
                inputStream.close();
                httpURLConnection.disconnect();
                return result;
            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return null;
    }

    @Override
    protected void onPreExecute() {
        alertDialog = new AlertDialog.Builder(context).create();
        alertDialog.setTitle("Login Status");
    }

    @Override
    protected void onPostExecute(String result) {
        alertDialog.setMessage(result);
        alertDialog.show();
    }

    @Override
    protected void onProgressUpdate(Void... values) {
        super.onProgressUpdate(values);
    }
}




<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
    android:id="@+id/myrl">

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textPersonName"
        android:ems="10"
        android:id="@+id/etUserName"
        android:layout_alignParentTop="true"
        android:layout_marginTop="47dp" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textPassword"
        android:ems="10"
        android:id="@+id/etPassword"
        android:layout_below="@+id/etUserName"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Login"
        android:id="@+id/btnLogin"
        android:layout_below="@+id/etPassword"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginLeft="48dp"
        android:layout_marginStart="48dp"
        android:layout_marginTop="50dp"
        android:onClick="OnLogin"/>
</RelativeLayout>




<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.programmingknowledge.mysqldemo" >
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>"
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>




<?php 
$db_name = "employee101";
$mysql_username = "root";
$mysql_password = "";
$server_name = "localhost";
$conn = mysqli_connect($server_name, $mysql_username, $mysql_password,$db_name);

?>




<?php 
require "conn.php";
$user_name = $_POST["user_name"];
$user_pass = $_POST["password"];
$mysql_qry = "select * from employee_data where username like '$user_name' and password like '$user_pass';";
$result = mysqli_query($conn ,$mysql_qry);
if(mysqli_num_rows($result) > 0) {
echo "login success !!!!! Welcome user";
}
else {
echo "login not success";
}

?>




























Searches related to android mysql login

android mysql server

android mysql client

android mysql app

android mysql php json

android php mysql json login

How to create Simple Login form using php in android

Android Login and Registration with Php and Mysql

PHP Android Tutorial Part

Android Login and Registration with PHP, MySQL

android php mysql sample code

android php mysql json tutorial

android studio mysql connection
IT Certification Category (English)640x480

Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com


Top Online Courses From ProgrammingKnowledge

Python Course http://bit.ly/2vsuMaS
Java Coursehttp://bit.ly/2GEfQMf
Bash Coursehttp://bit.ly/2DBVF0C
Linux Coursehttp://bit.ly/2IXuil0
C Course http://bit.ly/2GQCiD1
C++ Coursehttp://bit.ly/2V4oEVJ
PHP Coursehttp://bit.ly/2XP71WH
Android Coursehttp://bit.ly/2UHih5H
C# Coursehttp://bit.ly/2Vr7HEl
JavaFx Coursehttp://bit.ly/2XMvZWA
NodeJs Coursehttp://bit.ly/2GPg7gA
Jenkins Course http://bit.ly/2Wd4l4W
Scala Coursehttp://bit.ly/2PysyA4
Bootstrap Coursehttp://bit.ly/2DFQ2yC
MongoDB Coursehttp://bit.ly/2LaCJfP
QT C++ GUI Coursehttp://bit.ly/2vwqHSZ