Pages

Login form using php,Ajax and jquery with mysql

Login form using php,Ajax and jquery with mysql, Redirect one to another page using ajax with return result.

Create a index.php and add this code to it

<html> <body> <div class="wrap-input100 validate-input" data-validate = "Enter username"> <input class="input100" type="text" id="user" name="username" placeholder="Email"> <span class="focus-input100" data-placeholder="&#xf207;"></span> </div> <div class="wrap-input100 validate-input" data-validate="Enter password"> <input class="input100" type="password" id="pass" name="pass" placeholder="Password"> <span class="focus-input100" data-placeholder="&#xf191;"></span> </div> <div class="container-login100-form-btn"> <input class="input100" type="button" id="logBtn" name="logBtn" placeholder="Login" value="Login"> </div> <script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> <script> $('#logBtn').click(function(event){ user = document.getElementById("user").value; password = document.getElementById("pass").value; $.ajax({ type:"POST", url:"Login.php", async: false, data: {user:user,password:password}, success: function(data){ alert(data); if(data=="admin"){ window.location="https://..Main/<file-name>.php"; } if(data=="user"){ window.location="https://.....<file-name>.php"; } } }); }); </script> </body> </html>
Create a Login.php

<?php

     $servername = "localhost";
     $username = "root";
     $password = "root";
     $dbname = "demo";

     $conn = new mysqli($servername, $username, $password, $dbname);

     $user = $_POST['user'];
     $pass = $_POST['password'];

     $sql = "SELECT * FROM users WHERE email='$user' AND pass='$pass'";

     $result = mysqli_query($conn, $sql);

     if (mysqli_num_rows($result) > 0) {
         $sql_1 = "SELECT * FROM users WHERE email='$user' AND pass='$pass' AND type='admin'";
          $result_1 = mysqli_query($conn, $sql_1);
         if (mysqli_num_rows($result_1) > 0){
             echo "admin";
             exit(0);
           }
            else{
            echo "user";
            exit(0);
         }

      } else {
         $msg = "username/password invalid";
         echo $msg;
      }

     mysqli_close($conn);
     ?>

laravel : Accessing The Request from URL using get method


To obtain an instance of the current HTTP request via dependency injection,you should type-hint the Illuminate\Http\Request class on your controller method.

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class CategoryController extends Controller
{
    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index(Request $request)
    {
  echo "==>".   $name = $request->input('name');
    }
}

web.php

Route::get('/category', 'CategoryController@index')->name('category');

http://127.0.0.1:8000/category?name=test

Laravel : How to call controller index function using routes

In Laravel  Let's go with the example using controller name is Product

1. Create controller in Controllers case sensitive name so, create like a example given example : ProductController.php

//controller path
<project_name>/app/Http/Controllers/<controller_name.php>
Example product controller

//controller path
<project_name>/app/Http/Controllers/ProductController.php

Laravel : setup laravel in localhost with linux

Laravel setup in localhost before we need basic requirement to fulfill laravel works, you will need to make sure your server meets the following requirements:
PHP >= 7.1.3
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
XML PHP Extension
Ctype PHP Extension
JSON PHP Extension
BCMath PHP Extension

Installing Laravel

Laravel utilizes Composer to manage its dependencies. So, before using Laravel, make sure you have Composer installed on your machine.

Linux Samba Server : share server files directory with linux or window pc

How to create a linux server to share directory of projects(php,.net java) with other linux system PC or window system PC. 

How to create a network share via Samba using the Command-line interface/Linux Terminal, simple and brief way targeting Windows users.

1. Install Samba in linux server 14.04 or 16.04 18.04

sudo apt-get update
sudo apt-get install samba  

Laravel 5 - Remove public from url and run without php artisan

In laravel it's easy to step to run laravel project without using php artisan serve and removing public from url also

Here are the steps to follow.

1. Renaming the server.php to index.php

2. Copy the .htaccess from public folder to root folder (example : admin main folder)

Laravel run/access without php artisan

Laravel is Framework of php language,  its access through command php artisan server but when we run the project using live/domain name then..

its

http://localhost/<project_name>/public/



linux Add or remove user from group

How can I add or remove user from group in linux / ubuntu /debian system.

 To create a user enter:

$ sudo adduser username


 To create a GROUP enter:

$ sudo groupadd groupname

 To Add user from GROUP enter:

$ sudo adduser username group name

To Remove User from GROUP enter:

$ sudo deluser user group

AJax, PHP Tutorial generate a random string/coupon code

How to call ajax with php its easy step to call ajax lets we go for more we need to pass a url in ajax to call php function/variable/data from php for without refresh the page


    $.ajax({   
url: "string.php",
method: 'post',
data: {type:'string_action',length: length},
dataType: 'html',
success: function(response){
  response=response.replace(/(\r\n|\n|\r)/gm,"");
     $('#p_code').val(response);
     
}
 });

Popular Posts