Topic: Mysql

Laravel Roles Permissions Example Tutorial From Scratch 0

Laravel Roles Permissions Example Tutorial From Scratch

Today, We want to share with you Laravel Roles Permissions Example Tutorial From Scratch.In this post we will show you Set-up role based access control in Laravel, hear for Implementing Roles & Permissions in Laravel we will give you demo and example for implement.In this post, we will learn about Laravel Manage User Roles And Permissions with an example.

Laravel Roles Permissions Example Tutorial From Scratch

There are the Following The simple About Laravel Roles Permissions Example Tutorial From Scratch Full Information With Example and source code.

As I will cover this Post with live Working example to develop LARAVEL 5 USERS AND ROLES MANAGEMENT, so the some major files and Directory structures for this example is following below.

  • Buid a Laravel migrations
  • Add a Form Select Box the registration form
  • Changes User Model
  • Changes Register Controller
  • Customization of the middlewares

Step 1 : Buid a Laravel migrations:

First of all You Include a new fields role column to our application existing user migration

Implementing Roles & Permissions in Laravel Migrations

//Create laravel user roles and permissions Database Migrations
Schema::create('users', function (Blueprint $table) {
    $table->increments('id');  // Uniq id
    $table->string('name');   // User name
    $table->string('email')->unique();
    $table->string('password');  // default Password
    $table->string('role');// the simple role column Adds
    $table->rememberToken();
    $table->timestamps(); //Created and updated time and date store
});

Run the Database migrations to Create the tables:

Run Below Commands

php artisan migrate

Step 2 : Add a Form Select Box the registration form

Now, simple Create the authentication Based scaffolding(Set-up role based access control in Laravel) which comes Main Data bundled with Laravel. and then run bellow commands.

Customize the registration form

php artisan make:auth

After That, You Some Changes in register.blade.php files.

Path : resources/views/auth/register.blade.php

<div class="pakainfo form-group row">
    <label for="role" class="col-md-4 col-form-label">Role</label>
    <div class="col-md-6">
        <select name="role" class="form-control" >
            <option value="superadmin">SuperAdmin</option>
            <option value="manager">Manager</option>
            <option value="member">Member</option>
        </select>
    </div>
</div>

Step 3 : Changes User Model and Controller in Laravel

Customize User Model and Register Controller

//User.php
protected $fillable = [
    'name', 'email', 'password','role',
];

Step 3.1 Laravel Form validator

Include a simple Laravel validation define a rule for the select box role field:

path : app/Http/Controllers/Auth/RegisterController.php

protected function validator(array $data)
{
    return Validator::make($data, [
        'name' => 'required|string|max:255',
        'email' => 'required|string|email|max:255|unique:users',
        'password' => 'required|string|min:6|confirmed',
        'role' => 'required|in:superadmin,manager,member', //custome validate role input
    ]);
}

Step 3.2 Laravel Cerate() Method

Laravel simple make a Cerate() Method in RegisterController

Include role Save or store field to the create() in Controller method:

protected function create(array $data)
{
	return User::create([
		'name' => $data['name'],
		'email' => $data['email'],
		'password' => bcrypt($data['password']),
		'role' => $data['role'],
	]);
}

Step 4 : Customization of the middlewares

I shall make a Laravel middlewares for most of case each of our roles.

Set-up Laravel middlewares

php artisan make:middleware SuperAdmin
php artisan make:middleware Manager
php artisan make:middleware Member

here simple Now, You Can Change this file Like as app/Http/Middleware directory

SuperAdmin.php:

//laravel user roles and permissions in SuperAdmin
use Auth; //at the First

function handle($request, Closure $next)
{
    if (Auth::check() && Auth::user()->role == 'superadmin') {
        return $next($request);
    }
    elseif (Auth::check() && Auth::user()->role == 'manager') {
        return redirect('/manager');
    }
    else {
        return redirect('/member');
    }
}

Manager.php:

//laravel user roles and permissions in Manager
use Auth; //at the first

function handle($request, Closure $next)
{
    if (Auth::check() && Auth::user()->role == 'manager') {
        return $next($request);
    }
    elseif (Auth::check() && Auth::user()->role == 'member') {
        return redirect('/member');
    }
    else {
        return redirect('/superadmin');
    }
}

Member.php:

//laravel user roles and permissions in Member
use Auth; //at the first

function handle($request, Closure $next)
{
    if (Auth::check() && Auth::user()->role == 'member') {
        return $next($request);
    }
    elseif (Auth::check() && Auth::user()->role == 'manager') {
        return redirect('/manager');
    }
    else {
        return redirect('/superadmin');
    }
}

Step 5: $routeMiddleware(Kernel.php)

Including the Laravel middleware classes to changes $routeMiddleware

Path : app/Http/Kernel.php

protected $routeMiddleware = [
    // ...
    'superadmin' => 'App\Http\Middleware\SuperAdmin',
    'manager' => 'App\Http\Middleware\Manager',
    'member' => 'App\Http\Middleware\Member',
];

Step 6 : Set-up Laravel Routes

some changes these Laravel middlewares to routes or to the controller

path : routes/web.php:

Route::get('/superadmin', function(){
    echo "Welcome To SuperAdmin";
})->middleware('auth','superadmin');

Route::get('/manager', function(){
    echo "Welcome To Manager";
})->middleware('auth','manager');

Route::get('/member', function(){
    echo "Welcome To Member";
})->middleware('auth','member');

specify a Laravel middleware used to dependent in a controller’s constructor,

Use Laravel controller’s constructor

public function __construct()
{
    $this->middleware('auth');
    $this->middleware('superadmin');
}

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel Roles Permissions Example Tutorial From Scratch.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Automatically Laravel Create dynamic generate sitemap 0

Automatically Laravel Create dynamic generate sitemap

Automatically Laravel Create dynamic generate sitemap

In this Post We Will Explain About is Automatically Laravel Create dynamic generate sitemapBuilding a Search Engine Friendly Sitemap XML with Laravel With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Example

In this post we will show you Best way to implement Generate a sitemap -> use Blade for xml-document, hear for Automatically generate a sitemap in Laravel 5with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Therefore, let’s follow some source code following Phase as well as use it. i provide just two Phase one for installing packages as well as second one for some example of sitemap generate.Laravel 5 generate sitemap using live24u/sitemap package Example

Step 1: Installation Package

first We have to fire following commas well as on We terminal as well as get latest version of “live24u/sitemap” package.

composer require live24u/sitemap

Add ServiceProvider

Ok, And then open config/app.php file as well as add service provider of That package.

'providers' => [

	....some code

	'Roumen\Sitemap\SitemapServiceProvider',

]

Publish Config File

following commas well as through We may create publish config file of “live24u/sitemap” package. after fire That commas well as We may see one file app/config/sitemap.php as well as We may change We own setting.

php artisan vendor:publish --provider="Roumen\Sitemap\SitemapServiceProvider"

Step 2: Example With Route

In Last Phase i provide example of how to generate sitmap. so first open app/Http/routes.php as well as add following route.

app/Http/routes.php

Route::get('sitemap', function(){

    /*Devloped by Pakainfo.com create new sitemap object */

    $sitemap = App::make("sitemap");

    

    /*Devloped by Pakainfo.com add item to the some sitemap parameters(url, date, priority, freq) */

    $sitemap->add(URL::to('/'), '2020-08-25T20:10:00+02:00', '1.0', 'daily');

    
 

    $datamsts = DB::table('datamst')

                ->select('datamst.*'

                    ,'datamst.title as datamstTitle','datamst.slug as datamstSlug'

                    ,'datamst_image.image as image','datamst.updated_at as datamstUpdated_at')

                    ->join('datamst_image','datamst_image.datamst_id','=','datamst.id')

                    ->orderBy('created_at','desc')

                    ->groupBy('datamst.id')

                    ->get();

    

    $data_slug_results = array();

    if(!empty($datamsts)){

        foreach ($datamsts as $key => $value) {

            $data_slug_results[$value->id]['id'] = $value->id;

            $data_slug_results[$value->id]['slug'] = $value->datamstSlug;

            $data_slug_results[$value->id]['datamstTitle'] = $value->datamstTitle;

            $data_slug_results[$value->id]['datamstUpdated_at'] = $value->datamstUpdated_at;

            $data_slug_results[$value->id]['image'][] = $value->image;

        }

    }

    

     /*Devloped by Pakainfo.com add every datamst to the sitemap */

     foreach ($data_slug_results as $key=>$value)

     {

        $images = array();

        foreach ($value['image'] as $key2 => $value2) {

            $images[] = array(

                'url' => URL::to('/')."/uploadImages/datamst/".$value2,

                'title' => $value['slug'],

                'caption' => $value['datamstTitle']

            );    

        }

        $sitemap->add(URL::route('front.datamst',$value['slug']), $value['datamstUpdated_at'], '1.0', 'daily', $images);

    }

    

    /* Devloped by Pakainfo.com show We are sitemap like as a (options: 'xml' (default), 'html', 'txt', 'ror-rss', 'ror-rdf') */

    return $sitemap->render('xml');

});

And then We may open sitemap route url as well as check output, it shell be like some preview. we may also get more some information of That data package from here : Wiki

Example

I hope you have Got What is Building a Search Engine Friendly Sitemap XML with Laravel And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

PHP Jquery Ajax CRUD Example Tutorial From Scratch 0

PHP Jquery Ajax CRUD Example Tutorial From Scratch

Today, We want to share with you PHP Jquery Ajax CRUD Example Tutorial From Scratch.In this post we will show you Jquery Ajax CRUD Operations in PHP, hear for PHP MySQL CRUD Operations using jQuery and Bootstrap we will give you demo and example for implement.In this post, we will learn about Simple PHP Jquery Ajax CRUD(insert update delete) tutorial example with an example.

PHP Jquery Ajax CRUD Example Tutorial From Scratch

There are the Following The simple About PHP Jquery Ajax CRUD Example Tutorial From Scratch Full Information With Example and source code.

As I will cover this Post with live Working example to develop CRUD Operation using PHP/MySQLi and AJAX/jQuery, so the some major files and Directory structures for this example is following below.

  • index.php
  • fetchMemberData.php
  • create.php
  • edit.php
  • update.php
  • delete.php
  • js/member-ajax.js

Step 1: Make Mysql Database and Table

Items Table Query:

CREATE TABLE IF NOT EXISTS `members` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `membername` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `member_info` text COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=63 ;

Step 1.1 create database configuration

api/config_database.php

<?php
//CRUD Operation using PHP/MySQLi and AJAX/jQuery
    $hostName = "localhost";
    $username = "root";
    $password = "root";
    $dbname = "atmiya25";
    $mysqli = new mysqli($hostName, $username, $password, $dbname);
?>

Step 2: Create HTML interface Index Page

index.php

This is where I will make a simple HTML form and PHP server side source code for our web application. To make the forms simply all souce code copy and write it into your any text editor Like Notepad++, then save file it as index.php.

<!DOCTYPE html>
<html>
<head>
    <title>PHP Jquery Ajax CRUD Example - pakainfo.com</title>
    <link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.js"></script>
 
    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/twbs-pagination/1.3.1/jquery.twbsPagination.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/1000hz-bootstrap-validator/0.11.5/validator.min.js"></script>
    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
    <link href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet">
    <script type="text/javascript">
        var url = "http://localhost:8000/";
    </script>
    <script src="/js/member-ajax.js"></script>
</head>
<body>
    <div class="container">
        <div class="row">
            <div class="col-lg-12 margin-tb">                    
                <div class="pull-left">
                    <h2>PHP Jquery Ajax CRUD Example</h2>
					<b>PHP Jquery Ajax CRUD Example Tutorial From Scratch</b>
                </div>
                <div class="pull-right">
                <button type="button" class="btn btn-success" data-toggle="modal" data-target="#create-member">
                      Create Member
                </button>
                </div>
            </div>
        </div>
        <table class="table table-bordered">
            <thead>
                <tr>
                <th>Member Name</th>
                <th>Member Information</th>
                <th width="200px">Action</th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
        <ul id="pagination" class="pakainfo pagination-sm"></ul>
        <!-- amke Member Modal -->
        <div class="modal fade" id="create-member" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
          <div class="modal-dialog" role="document">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="myModalLabel">Create Member</h4>
              </div>
              <div class="modal-body">
                      <form data-toggle="validator" action="api/create.php" method="POST">
                          <div class="form-group">
                            <label class="control-label" for="membername">Member Name:</label>
                            <input type="text" name="membername" class="form-control" data-error="Please enter membername." required />
                            <div class="help-block with-errors"></div>
                        </div>
                        <div class="form-group">
                            <label class="control-label" for="membername">Member Information:</label>
                            <textarea name="member_info" class="form-control" data-error="Please enter member_info." required></textarea>
                            <div class="help-block with-errors"></div>
                        </div>
                        <div class="form-group">
                            <button type="submit" class="btn crud-submit btn-success">Submit</button>
                        </div>
                      </form>
              </div>
            </div>
          </div>
        </div>
        <!-- Edit Member Modal -->
        <div class="modal fade" id="edit-member" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
          <div class="modal-dialog" role="document">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="myModalLabel">Edit Member</h4>
              </div>
              <div class="modal-body">
                      <form data-toggle="validator" action="api/update.php" method="put">
                          <input type="hidden" name="id" class="edit-id">
                          <div class="form-group">
                            <label class="control-label" for="membername">Member Name:</label>
                            <input type="text" name="membername" class="form-control" data-error="Please enter membername." required />
                            <div class="help-block with-errors"></div>
                        </div>
                        <div class="form-group">
                            <label class="control-label" for="membername">Member Information:</label>
                            <textarea name="member_info" class="form-control" data-error="Please enter member_info." required></textarea>
                            <div class="help-block with-errors"></div>
                        </div>
                        <div class="form-group">
                            <button type="submit" class="btn btn-success crud-submit-edit">Submit</button>
                        </div>
                      </form>
              </div>
            </div>
          </div>
        </div>
    </div>
</body>
</html>

Step 3: Make PHP jQuery CRUD JS File

js/member-ajax.js

$( document ).ready(function() {
var page = 1;
var current_page = 1;
var total_page = 0;
var is_ajax_fire = 0;
manageData();
/* manage data list */
function manageData() {
    $.ajax({
        dataType: 'json',
        url: url+'api/fetchMemberData.php',
        data: {page:page}
    }).done(function(data){
        total_page = Math.ceil(data.total/10);
        current_page = page;
        $('#pagination').twbsPagination({
            totalPages: total_page,
            visiblePages: current_page,
            onPageClick: function (event, pageL) {
                page = pageL;
                if(is_ajax_fire != 0){
                  getPageData();
                }
            }
        });
        manageRow(data.data);
        is_ajax_fire = 1;
    });
}
/* Get Page Data*/
function getPageData() {
    $.ajax({
        dataType: 'json',
        url: url+'api/fetchMemberData.php',
        data: {page:page}
    }).done(function(data){
        manageRow(data.data);
    });
}
/* Add new Member table row */
function manageRow(data) {
    var    rows = '';
    $.each( data, function( key, value ) {
          rows = rows + '<tr>';
          rows = rows + '<td>'+value.membername+'</td>';
          rows = rows + '<td>'+value.member_info+'</td>';
          rows = rows + '<td data-id="'+value.id+'">';
        rows = rows + '<button data-toggle="modal" data-target="#edit-member" class="btn btn-primary edit-member">Edit</button> ';
        rows = rows + '<button class="btn btn-danger remove-member">Delete</button>';
        rows = rows + '</td>';
          rows = rows + '</tr>';
    });
    $("tbody").html(rows);
}
/* Create new Member */
$(".crud-submit").click(function(e){
    e.preventDefault();
    var form_action = $("#create-member").find("form").attr("action");
    var membername = $("#create-member").find("input[name='membername']").val();
 
    var member_info = $("#create-member").find("textarea[name='member_info']").val();
    if(membername != '' && member_info != ''){
        $.ajax({
            dataType: 'json',
            type:'POST',
            url: url + form_action,
            data:{membername:membername, member_info:member_info}
        }).done(function(data){
            $("#create-member").find("input[name='membername']").val('');
            $("#create-member").find("textarea[name='member_info']").val('');
            getPageData();
            $(".modal").modal('hide');
            toastr.success('Member Created Successfully.', 'Success Alert', {timeOut: 5000});
        });
    }else{
        alert('You are missing membername or member_info.')
    }
});
/* Remove Member */
$("body").on("click",".remove-member",function(){
    var id = $(this).parent("td").data('id');
    var c_obj = $(this).parents("tr");
    $.ajax({
        dataType: 'json',
        type:'POST',
        url: url + 'api/delete.php',
        data:{id:id}
    }).done(function(data){
        c_obj.remove();
        toastr.success('Member Deleted Successfully.', 'Success Alert', {timeOut: 5000});
        getPageData();
    });
});
/* Edit Member */
$("body").on("click",".edit-member",function(){
    var id = $(this).parent("td").data('id');
    var membername = $(this).parent("td").prev("td").prev("td").text();
    var member_info = $(this).parent("td").prev("td").text();
 
    $("#edit-member").find("input[name='membername']").val(membername);
    $("#edit-member").find("textarea[name='member_info']").val(member_info);
    $("#edit-member").find(".edit-id").val(id);
});
/* Updated new Member */
$(".crud-submit-edit").click(function(e){
    e.preventDefault();
    var form_action = $("#edit-member").find("form").attr("action");
    var membername = $("#edit-member").find("input[name='membername']").val();
    var member_info = $("#edit-member").find("textarea[name='member_info']").val();
    var id = $("#edit-member").find(".edit-id").val();
    if(membername != '' && member_info != ''){
        $.ajax({
            dataType: 'json',
            type:'POST',
            url: url + form_action,
            data:{membername:membername, member_info:member_info,id:id}
        }).done(function(data){
            getPageData();
            $(".modal").modal('hide');
            toastr.success('Member Updated Successfully.', 'Success Alert', {timeOut: 5000});
        });
    }else{
        alert('You are some missing membername or member_info.')
    }
});
});

Step 4: Make a Server Side AJAX File Call and Crud PHP

api/fetchMemberData.php

<?php
require 'config_database.php';
$num_rec_per_page = 5;
if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * $num_rec_per_page;
$sqlTotal = "SELECT * FROM members";
$sql = "SELECT * FROM members Order By id desc LIMIT $start_from, $num_rec_per_page"; 
$db_query_results = $mysqli->query($sql);
  while($row = $db_query_results->fetch_assoc()){
     $json[] = $row;
  }
  $data['data'] = $json;
$db_query_results =  mysqli_query($mysqli,$sqlTotal);
$data['total'] = mysqli_num_rows($db_query_results);
echo json_encode($data);
?>

Jquery Ajax CRUD Operations in PHP Create Member

api/create.php

<?php
require 'config_database.php';
  $post = $_POST;
  $sql = "INSERT INTO members (membername,member_info) 
    VALUES ('".$post['membername']."','".$post['member_info']."')";
  $db_query_results = $mysqli->query($sql);
  $sql = "SELECT * FROM members Order by id desc LIMIT 1"; 
  $db_query_results = $mysqli->query($sql);
  $data = $db_query_results->fetch_assoc();
echo json_encode($data);
?>

Jquery Ajax CRUD Operations in PHP Update

api/update.php

<?php
  require 'config_database.php';
  $id  = $_POST["id"];
  $post = $_POST;
  $sql = "UPDATE members SET membername = '".$post['membername']."'
    ,member_info = '".$post['member_info']."' 
    WHERE id = '".$id."'";
  $db_query_results = $mysqli->query($sql);
  $sql = "SELECT * FROM members WHERE id = '".$id."'"; 
  $db_query_results = $mysqli->query($sql);
  $data = $db_query_results->fetch_assoc();
  echo json_encode($data);
?>

crud php mysql ajax bootstrap – delete

api/delete.php

<?php
 require 'config_database.php';
 $id  = $_POST["id"];
 $sql = "DELETE FROM members WHERE id = '".$id."'";
 $db_query_results = $mysqli->query($sql);
 echo json_encode([$id]);
?>

run this example on terminal run commands

php -S localhost:8000

run Web Project and Browser URL

http://localhost:8000

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PHP Jquery Ajax CRUD Example Tutorial From Scratch.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

PHP Web Application create Installer scripts 1

PHP Web Application create Installer scripts

Today, We want to share with you PHP Web Application create Installer scripts.In this post we will show you , hear for php project install script we will give you demo and example for implement.In this post, we will learn about How To Create User-Friendly PHP Script Installation with an example.

PHP Web Application create Installer scripts

There are the Following The simple About PHP Web Application create Installer scripts Full Information With Example and source code.

As I will cover this Post with live Working example to develop PHP Installer: Create PHP application install scripts, so the some major files and Directory structures for this example is following below.

Connecting to MySQL with PHP

database-app
->data(folder)
-->init.sql
->public
-->css
--->style.css
->templates
-->footer.php
-->header.php
->common.php
->config.php
->intall.php

database-app/data/init.sql

CREATE DATABASE memberlist;

use memberlist;

CREATE TABLE members (
	id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY, 
	memberfname VARCHAR(30) NOT NULL,
	memberlname VARCHAR(30) NOT NULL,
	membermail VARCHAR(50) NOT NULL,
	memberage INT(3),
	membercity VARCHAR(50),
	date TIMESTAMP
);

database-app/config.php

<?php
$host       = "localhost";
$databaseuname   = "root";
$password   = "";
$dbname     = "memberlist";
$dsn        = "mysql:host=$host;dbname=$dbname";
$config_op    = array(
                PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
              );

database-app/intall.php

<?php
require "config.php";

try {
    $connection = new PDO("mysql:host=$host", $databaseuname, $password, $config_op);
    $sql = file_get_contents("data/init.sql");
    $connection->exec($sql);
    
    echo "Database and table members created successfully.";
} catch(PDOException $error) {
    echo $sql . "<br>" . $error->getMessage();
}

database-app/common.php

<?php
function escape($html) {
    return htmlspecialchars($html, ENT_QUOTES | ENT_SUBSTITUTE, "UTF-8");
}

database-app/public/index.php

<?php include "templates/header.php"; ?>

<ul>
	<li><a href="create.php"><strong>Create</strong></a> - add a member</li>
	<li><a href="read.php"><strong>Read</strong></a> - find a member</li>
</ul>

<?php include "templates/footer.php"; ?>

database-app/public/create.php

<?php
if (isset($_POST['submit'])) {
    require "../config.php";
    require "../common.php";

    try  {
        $connection = new PDO($dsn, $databaseuname, $password, $config_op);
        
        $new_member = array(
            "memberfname" => $_POST['memberfname'],
            "memberlname" => $_POST['memberlname'],
            "membermail"  => $_POST['membermail'],
            "memberage"   => $_POST['memberage'],
            "membercity"  => $_POST['membercity']
        );

        $sql = sprintf(
                "INSERT INTO %s (%s) values (%s)",
                "members",
                implode(", ", array_keys($new_member)),
                ":" . implode(", :", array_keys($new_member))
        );
        
        $mystmt = $connection->prepare($sql);
        $mystmt->execute($new_member);
    } catch(PDOException $error) {
        echo $sql . "<br>" . $error->getMessage();
    }
}
?>

<?php require "templates/header.php"; ?>

<?php if (isset($_POST['submit']) && $mystmt) { ?>
    <blockquote><?php echo $_POST['memberfname']; ?> successfully added.</blockquote>
<?php } ?>

<h2>Add a Member</h2>

<form method="post">
    <label for="memberfname">Member Name</label>
    <input type="text" name="memberfname" id="memberfname">
    <label for="memberlname">Member Sir Name</label>
    <input type="text" name="memberlname" id="memberlname">
    <label for="membermail">Email of Member</label>
    <input type="text" name="membermail" id="membermail">
    <label for="memberage">Member Age</label>
    <input type="text" name="memberage" id="memberage">
    <label for="membercity">City</label>
    <input type="text" name="membercity" id="membercity">
    <input type="submit" name="submit" value="Submit">
</form>

<a href="index.php">Back to home</a>

<?php require "templates/footer.php"; ?>

database-app/public/templates/footer.php

<p>PHP Installer Create PHP application install scripts</p>
</body>

</html>

database-app/public/templates/header.php

<!doctype html>
<html lang="en">

<head>
	<meta charset="utf-8">
	<meta http-equiv="x-ua-compatible" content="ie=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">

	<title>Learn how to create an Installer of your PHP Project</title>

	<link rel="stylesheet" href="css/style.css">
</head>

<body>
	<h1>PHP Web Application Installer scripts</h1>

database-app/public/css/style.css

label {
	display: block;
	margin: 10px 0;
}

table {
	border-collapse: collapse;
	border-spacing: 0;
}

td,
th {
	padding: 15px;
	border-bottom: 1px solid #3d3d3d;
}

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PHP Web Application create Installer scripts.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.