Top SEO Strategies that You Should Follow in 2019

If you really want to be ahead of the game, it’s not enough to keep an eye on the latest trends, you should also foresee some of them. But is it really possible? The answer would be – yes and no. The thing is that we can’t predict what surprises search engines prepare for us. However, we still can make some predictions according to the latest announcements and taking off trends. There’s my list:

1. User experience

Google makes everything to serve clients, so it thinks about bunches of purported ‘social’ factors while positioning sites. Additionally, I’m certain you might want to enhance the change rate and increment time spent on your site. That is the reason ensure the client is happy with your site beginning from the substance and completing with the structure.

Pay attention to such user experience signals as:

  • Organic CTR (Click-Through-Rate).
  • Dwell Time.
  • Bounce Rate.
  • Pogo-sticking.

So how can you improve them? There some most important techniques:

  • Optimize Title and Description tags for better CTR.
  • Create in-depth content.
  • Use LSI keywords.
  • Improve usability.
  • Increase page load speed.

2. Mobile first

These days around 60% of Google seeks are produced using cell phones (in a few specialties numbers go up to 90%). That is the reason Google has effectively taken off portable first ordering and will make the web progressively versatile well disposed later on. So ensure your site has responsive plan (I propose utilizing it rather than independent portable adaptation) or both versatile and work area forms have equal substance.

3. Video content

How frequently do you find yourself viewing a 15-minute video as opposed to perusing a major article (despite the fact that it’s consummately advanced and may answer your inquiry)? As per the examination of systems administration monster Cisco, video substance will take around 80% of all online traffic by 2021. So on the off chance that despite everything you rest on video content, consider it in 2019. I propose consolidating video content with your content articles, however keep in mind that YouTube recordings ought to likewise be SEO-enhanced.

4. Voice search

Google voice seek is not any more about calling a telephone number and advising watchwords you need to observe as it used to return in 2010. These days an ever increasing number of individuals lean toward utilizing voice inquiries and directions (around 20% of versatile hunts are made by voice). The fate of voice seek is as yet obscure, yet it will unquestionably keep on ending up increasingly insightful, responsive, and precise. So you should consider a few parts of SEO that influence voice seek:

  • Optimization of featured snippets.
  • Long-tail voice-oriented keywords.
  • Schema Metadata.
  • Local SEO.

5. Featured snippets

In the event that you make an inquiry utilizing a mainstream watchword, you would likely observe not just paid and natural outcomes in SERP as it used to be 10 years back yet in addition an assortment of highlighted scraps (information diagram, rich answers, moment usefulness and so on.). Google fills its SERP with increasingly more non-natural outcomes, which is particularly observable on cell phones. The content, video or picture are taken straightforwardly from the website page that is connected to in the bit. So in the event that you improve your page for the included scrap, it might show up at the simple best of SERP.

How to get featured:

Make sure your page already ranks high (according to Ahrefs, 99.58% of featured pages rank in top 10 of Google)
Ask the question in your article and answer it (use several questions in subheadings to cover more queries, but don’t overdo)
Use eye-catching images and videos

6. Content optimization and technical SEO

When concentrating on patterns, you ought to always remember about fundamental on-page SEO. Having specialized issues, for example, low page stack speed, copy content or missing Title and Description meta labels, will pulverize every one of your endeavors. I suggest checking your site with Netpeak Spider which will locate all fundamental on-page issues and begin settling them.

Remember that despite the fact that you may know just some most well known Google calculations/refreshes as Panda, Penguin, Fred or Hummingbird, Google makes 2-3 algorithmic updates each day. What I mean is that in 2019 Google will be considerably more insightful, so it will be increasingly hard to advance your site if it’s bad enough. Make amazing substance, streamline your site, monitor the most recent patterns and you’ll succeed!

PHP Web Services: How to Create a Simple Web Service Using PHP

A quick tutorial to explain what a Web Service is and how it can be used. Let see with step by step

What is Web Service ?

The main question arise before starting implementation of web services is what does mean by Web Service and What is the Web Service.Simply we can understand this Web Service by some definitions.

  • Web service is a client server application or application component for communication between client and server.
  • Web service is a software system for inter operable machine to machine communication..
  • Web service provide a common platform that allows to communicate between multiple applications with each other, which built on various programming languages.

Types of Web Services:

There are two types of web services.

1.) SOAP web services.

2.) RESTful web services.

SOAP Web Service:

SOAP stands for Simple Object Access Protocol. It is a XML-based protocol for accessing Web Services.

SOAP is XML based protocol known as platform independent and language independent. By using SOAP, you will be able to interact with other programming language applications.

RESTful Web Service(Also Known as REST API):

RESTful web service is based on representational state transfer (REST) technology. It is an architectural style and an approach for communication used in the development of Web Services.

Some Benefits of REST APIs:

  • REST APIs are fast.
  • No strict specification like SOAP.
  • Consumes less bandwidth and resource.
  • Language and Platform independent.
  • Can be written in any programming language.
  • Executed in any platform.
  • RESTful web services can use SOAP web services.
  • Permits different data format like Plain Text, HTML, XML and JSON.

Creating a Simple REST API:

I am going to create a simple REST API. In this API trying to get employee data based on search by employee id.To read this API i will use CURL method.

Create a form named Employees.php where an input box will get employee id from user.Please find below the code.

<!DOCTYPE html>
<html>
    <head>
        <title>Simple REST API</title>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    </head>
    <body>
    <center>
    <?php
    if(!empty($result)){
        echo "<table>";
        echo "<tr><td>Employee ID:</td><td>$result->employeeid</td></tr>";
        echo "<tr><td>NAme:</td><td>$result->employeeName</td></tr>";
        echo "<tr><td>Age:</td><td>$result->employeeAge</td></tr>";
        echo "<tr><td>Salary:</td><td>$result->employeeSalary</td></tr>";
        echo "<tr><td>Response Code:</td><td>$result->responseCode</td></tr>";
        echo "</table>";
    }
    ?>
        <div class="container">
            <form action="" method="POST">
            <label>Enter Employee ID:</label><br />
            <input type="number" name="employee_id" placeholder="Enter Employee ID" required/>
            <br /><br />
            <button type="submit" name="submit">Submit</button>
            </form>
        </div>
    </center>
    </body>
</html>
In the same page we will put PHP script which will execute after form submitting.
<?php
if (isset($_POST['employee_id']) && $_POST['employee_id']!="") {
$employee_id = $_POST['employee_id'];
$url = "http://localhost/rest_api_example/api/".$employee_id;
$client = curl_init();
curl_setopt_array($client, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0
));
    $response = curl_exec($client);
$result = json_decode($response);
}
?>
Above script handling of API Call. Simply passing employee id through API and we will get the response.
Now, We will create the API named API.php where the write code to return employee data against employee id with response code.Please find below the API code.
<?php
header("Content-Type:application/json");
if (isset($_GET['employeeid']) && $_GET['employeeid']!="") {
include('./connection.php');
$db = new dbObj();
$con = $db->getConnstring();
$employeeid = $_GET['employeeid'];
$result = mysqli_query($con,
"SELECT * FROM `employee` WHERE id = $employeeid");
if(mysqli_num_rows($result)>0){
$row = mysqli_fetch_array($result);
$employeeName = $row['employee_name'];
$employeeAge = $row['employee_age'];
$employeeSalary = $row['employee_salary'];
$responseCode = 200;
response($employeeid, $employeeName, $employeeAge,$employeeSalary,$responseCode);
mysqli_close($con);
}else{
response(NULL, NULL, NULL,"No Record Found",200);
}
}else{
response(NULL, NULL, NULL,"Invalid Request",400);
}

function response($employeeid,$employeeName,$employeeAge,$employeeSalary,$responseCode){
$response = array(
      'employeeid' => $employeeid,
    'employeeName' => $employeeName,
    'employeeAge'=> $employeeAge,
    'employeeSalary' => $employeeSalary,
    'responseCode'=> $responseCode
    );
$json_response = json_encode($response);
echo $json_response;
}
?>

Clean URL through htaccess:

Clean URL also known as RESTful URL are user-friendly and do not contain a query string. Rather than they contain only the path of the resource.Please find below the code of htaccess.

RewriteEngine On # Turn on the rewriting engine
RewriteRule ^api/([0-9a-zA-Z_-]*)$ api.php?employeeid=$1 [NC,L]

Note: When you are testing this API example make sure CURL is enabled on your web server or on your localhost.

That’s all.Head to your browser and run this example.

Final Words:

This example simply getting employee data through an API, which can be used through calling that API and we will get all employee data as per required format like JSON, XML or Plain Text.
Thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion. if you face any issue with this code let us know. We’d love to help. Stay tuned !

Laravel Validation and Rules: Validate Inputs using Laravel Validator Class and display errors

Validate-Inputs-using-Laravel-Validator-Class-and-displa-errors

Of course validation is a very important part of our web application development.When it comes to implement validation from backend,laravel has inbuilt validation class that provides few unique ways to deal with validation in your application’s coming data.

In this tutorial we will see how to use validator class to validate inputs in laravel application.

Validation inside Controller(From Controller’s Approach):

This validation I am going to implement from controller. Please find below the code.

<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Response;
use \Illuminate\Support\Facades\Redirect;
use Illuminate\Http\Request;
use Validator;
class AddressController extends Controller
{
public function index(){
return view('create');
}public function insert(Request $request){
$validator = Validator::make($request-&gt;all(), [
'name'=>'required',
'email'=>'required|email',
'mobilenumber'=>'required|regex:/[0-9]{10}/|digits:10'
]);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator->getMessageBag()->toArray());
}else{
// Do your stuff
}
}
In the above validation it states that if the validation fails then the method creates a proper error message and send it back to the view. If the validation passes, it will just execute the code inside the action.
To check laravel validation rules go through Laravel Validation rules list

First Fails and Stop Next:

Laravel has rule to Stop On First Validation Failure.Sometimes you may wish to stop running validation rules on an attribute after the first validation failure. To do so, we can set bail rule :with first rule validation.Find below the example.

$validator = Validator::make($request->all(), [
'name'=>'bail | required',
'email'=>'required|email',
'mobilenumber'=>'required|regex:/[0-9]{10}/|digits:10'
]);
​That’s All,thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion. if you face any issue with this tutorial let us know. We’d love to help! Get in touch with us.

URLs Scrapper: How to Extract all URLs from a Web Page using PHP

It is sometimes required to extract all URLs from web page on demand.Lots of online tools are available to extract all URLs from a web page.This tutorial shows how to do that using PHP Script.This type of scrapper is may use to build sitemap generator or fetching Google result links.

To extract web URLs List from a web page I am going to use DOMdocument class of PHP. The DOM parser functions are part of the PHP core. No installation needed to use these functions.DOMDocument is very good at dealing with HTML as well as XML.In PHP, Just you need to create an instance of DOMDocument and initialize it, and set its version and character encoding.Let See how to do this.

<?php
$url = "https://techalltype.com/";
$html = file_get_contents($url);
$doc = new \DOMDocument('1.0', 'UTF-8'); /* instance of DOMDocument */
@$doc->loadHTML($html); /*The function parses the HTML contained in the string source */
$xpath = new \DOMXpath($doc); /*to retrieve selected html data */
$nodes = $xpath->query('//a');
foreach($nodes as $key => $node) {
echo $key++.".) ".$node->getAttribute('href')."<br/>";
}
?>

Here you can find more about on PHP DOMDocument.

​That’s All,thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion.

MySQL Remote Access: How to Connect MySQL Database Remotely using Codeigniter

How-to-Connect-MySQL-Database-Remotely-using-Codeigniter

MySQL is a popular database along with PHP applications. Sometime we need to connect MySQL Remotely. In this tutorial we will see how to connect MySQL Database Remotely.Let follow me step by step.

Remote Database Connection Setup(In Codeigniter):

To setup database connection in codeigniter application go to the file inside application/config named database.php and change database credentials as showing below.

$db['default'] = array(
    'dsn'  => '',
    'hostname' => 'Use the Remote Server IP Address', /* For Example: 103.120.176.47 */
    'username' => 'Remote MySQL Database User Name',
    'password' => 'Remote MySQL Database User Password if Applicable',
    'database' => 'Remote MySQL Database Name',
    'dbdriver' => 'mysqli',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

Allowing a Remote Server to Access Your Database(MySQL Remote Access – From cPanel):

Before connecting to MySQL from another server or computer, the connecting server or computer must be enabled as an Access Host.To Enable Access Host you need to allow remote server’s IP address. To set IP address go to the cPanel and follow these steps.

  • Log into cPanel and click the Remote MySQL icon, under Databases.

remote-my-sql

  • Type IP address in the host box, and click the Add Host button.

add-access-host

  • Click Add, and you should now be able to connect remotely to your database.

​That’s All,thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion. if you face any issue with this tutorial let us know. We’d love to help!

Connect using PuTTY: Connect to AWS Instance using SFTP(PuTTY)

Connect-to-AWS-Instance-using-SFTP

In this post I would like to show how to connect AWS account through SFTP(Secure File Transfer Protocol).PuTTY is a popular SSH, Telnet, and SFTP client for Windows. It is typically used for remote access to server computers over a network using the SSH protocol.Lets see how to connect.

Setup Host Name in PuTTY:

To start using putty we need host name or IP address.We can use Domain name or Public IP Address from AWS as a Host Name.

put-host-name-in-putty

Setup Your PPK File in PuTTY:

After you generating PPK file you have to use this to enable communication securely with AWS having the corresponding public key.To fut PPK file go to the SSH->Auth section and browse to your PPK file.

put-ppk-file-in-putty-auth

Connect to the Server:

Once you setup Host and PPK file then you can connect to the server by clicking open button.After that you will get below screen.

screen-after-connect-putty

Increase Connection Time in PuTTY:

If you want to increase connection time between PuTTY and AWS then go to your putty settings -> Connection and set the value of “Seconds between keepalives” to 30 seconds.After that connection time will be increase.

Thats All,thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion. if you face any issue with this tutorial let us know. We’d love to help!

Email using AWS SES: How to Send Email using AWS SES in Codeigniter

In this post I would like to show how to send email using AWS SES(Simple Email Service). Here I will use codeigniter framework to send Email. Lets start with step by step.

You may also like this post How to Send SMS using AWS SNS.

I am assuming that you already know about setup of codeigniter.If you have any issue with codeigniter setup then you can check this post Codeigniter Setup.

Get Client key and Client Secret key from AWS:

Login to your aws console. here you can find the Menu “My Billing Dashboard” under profile area.Inside of Access keys (access key ID and secret access key) you need to create new access key and save it to use in future.

Installation and Configuration AWS SDK in codeigniter:

To setup AWS SDK with codeigniter, need to install AWS SDK using composer. You can get it easily installed.Go to your root folder of the codeigniter application and run Below command.

composer require aws/aws-sdk-php

Creating Controller( Email using AWS SES ):

Next, we are going to create a controller file named AwsSesController.php inside application/controllers where we will put all Email configuration and send email function.Please find below the code.

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
use Aws\Common\Aws;
use Aws\Ses\SesClient;
class AwsSesController extends CI_Controller {
publicfunction __construct()
{
parent::__construct();
}
publicfunction sendEmail(){

$params = array(
'credentials'=> array(
'key'=>'CLIENT KEY',
'secret'=>'CLIENT SECRET KEY',
),
'region'=>'us-east-1',
'version'=>'latest'
);
$SesClient = new SesClient($params);

$sender_email = 'hitesh.maity@gmail.com';
$recipient_emails = ['hitesh.maity@gmail.com'];

// Specify a configuration set. If you do not want to use a configuration comment it or delete.
//$configuration_set = 'ConfigSet';

$subject = 'Test Email From Techalltype';
$plaintext_body = 'This email was sent with Amazon SES using the AWS SDK for PHP.' ;
$html_body = '<h1>Test Email From Techalltype</h1>';
$char_set = 'UTF-8';

try {
$result = $SesClient->sendEmail([
'Destination'=> [
'ToAddresses'=> $recipient_emails,
],
'ReplyToAddresses'=> [$sender_email],
'Source'=> $sender_email,
'Message'=> [
'Body'=> [
'Html'=> [
'Charset'=> $char_set,
'Data'=> $html_body,
],
'Text'=> [
'Charset'=> $char_set,
'Data'=> $plaintext_body,
],
],
'Subject'=> [
'Charset'=> $char_set,
'Data'=> $subject,
],
],
// If you aren't using a configuration set, comment or delete the following line
//'ConfigurationSetName' => $configuration_set,
]);
$messageId = $result['MessageId'];
echo("Email sent! Message ID: $messageId"."\n");
} catch (AwsException $e) {
// output error message if fails
echo $e->getMessage();
echo("The email was not sent. Error message: ".$e->getAwsErrorMessage()."\n");
echo "\n";
}
}
}

Moving Out from AWS SES Sandbox mode:

Above Email addresses must be verified with Amazon SES. By default Your Amazon SES account has “sandbox” access.With sandbox access you can only send email to the Amazon SES mailbox simulator and to email addresses or domains that you have verified. To move out from the sandbox access, you have to request a sending limit increase. After that you will get a reply from AWS Support which is about to how you are now ensuring that your mailing list contains only recipients who specifically signed up to receive email from you. And this question arises by AWS support, if you choose YES for the option (I only send to recipients who have specifically requested my mail).

Do not worry about reply.You just do reply them “Our mailing list contains only recipients who specifically signed up to receive email from us“.

Thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion. if you face any issue with this code let us know. We’d love to help!

Codeigniter File Uploading: Single and Multiple file Uploading with Codeigniter

In this tutorial we will see how file uploading process will be done by using codeigniter file upload class.It is very easy to handle all file uploading processes with codeigniter upload class which comes with various inbuilt configuration.Let see step by step how to achieve this.

Key Features of Codeigniter Uploading Class:

  • Various Inbuilt Settings.
  • File Validations.
  • Easy to configure.

Single file Uploading:

Single file uploading, where you can upload one file at a time.Lets see how to implement single file uploading.

1. Create a view file named upload.php inside  application/views directory.

<!DOCTYPE html>
<html>
<head>
<title>TechAllType</title>
</head>
<body>
<center>
<h4><?php
if(!empty($this->session->flashdata('success'))){
echo $this->session->flashdata('success');
}
if(!empty($this->session->flashdata('error'))){
echo $this->session->flashdata('error');
}
?></h4>
<form method="post" enctype="multipart/form-data" action="<?php echo base_url('<span style="color: #333333;">UploadController</span>/upload_file'); ?>">
<fieldset>
<legend>Personal Info</legend>
<table>
<tr>
<td>Name :</td><td><input type="text" name="name"></td>
</tr>
<tr>
<td>Email :</td><td><input type="text" name="email"></td>
</tr>
<tr>
<td>File :</td><td><input type="file" name="myfile"></td>
</tr>
<tr>
<td><input type="submit" name="upload"></td><td></td>
</tr>
</table>
</fieldset>
</form>
</center>
</body>
</html>

2. After done with the view file, next we need to create a controller. Create a controller file called UploadController.php inside application/controllers directory. Here we will load upload library.You can also load upload library globally inside application/config/autoload.php.

Please find below the controller’s code.

UploadController.php

<?php

class <span style="color: #333333;">UploadController</span> extends CI_Controller{
function __construct(){
parent::__construct();
$this->load->model('UploadModel');
}
public function index(){
$this->load->view('upload');
}
public function upload_file(){
$file_data='';

/* configuration and validations */
$config['upload_path'] = 'uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 100;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$config['file_name'] = $_FILES['myfile']['name'];
$this->load->library('upload', $config);
$this->upload->initialize($config);
if($this->upload->do_upload('myfile')){
$file_data = $this->upload->data();
}
else{
// echo $this->upload->display_errors();
$this->session->set_flashdata('error',$this->upload->display_errors());
redirect('UploadController');
}
$data = array(
'name' => $this->input->post('name'),
'email' => $this->input->post('email'),
'photo' => $file_data['file_name']
);
$this->UploadModel->insert_data($data);
$this->session->set_flashdata('success','Detail has been successfully inserted !');
redirect('UploadController');
}
}
?>

3. Next, You need to create a model. Purpose of create a model is to insert all file detail into database, which is being uploaded.Here is how code looks.

UploadModel.php

<?php
class UploadModel extends CI_Model{
function __construct(){
parent:: __construct();
}
public function insert_data($data){
$this->db->insert('upload',$data);
}
}
?>

Multiple file Uploading:

Multiple file uploading, where you can upload multiple file at a time.Lets see how to implement multiple file uploading.

1. View: MultipleUpload.php

<!DOCTYPE html>
<html>
<head>
<title>TechAllType</title>
</head>
<body>
<center>
<h4><?php
if(!empty($this->session->flashdata('success'))){
echo $this->session->flashdata('success');
}
if(!empty($this->session->flashdata('error'))){
echo $this->session->flashdata('error');
}
?></h4>
<form method="post" enctype="multipart/form-data" action="<?php echo base_url('<span style="color: #333333;">MultipleFileUploadController</span>/upload_file'); ?>">
<fieldset>
<legend>Personal Info</legend>
Gallery Id: <input type="text" name="gallery_id"><br><br>
File : <input type="file" name="myfile[]" multiple="multiple"><br><br>
<input type="submit" name="upload"><br>
</fieldset>
</form>
</center>
</body>
</html>

There is no big difference between single and multiple file input only need to include a multiple attribute with input file type.

2. Controller: MultipleFileUploadController.php

<?php

class MultipleFileUploadController extends CI_Controller{
function __construct(){
parent::__construct();
$this->load->model('MultipleFileUploadModel');
}
public function index(){
$this->load->view('MultipleUpload');
}
public function upload_file(){
$count = count($_FILES['myfile']['name']);
for ($i=0; $i < $count; $i++) {
$_FILES['file']['name'] = $_FILES['myfile']['name'][$i];
$_FILES['file']['type'] = $_FILES['myfile']['type'][$i];
$_FILES['file']['tmp_name'] = $_FILES['myfile']['tmp_name'][$i];
$_FILES['file']['error'] = $_FILES['myfile']['error'][$i];
$_FILES['file']['size'] = $_FILES['myfile']['size'][$i];
$config['upload_path'] = 'uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 100;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$config['file_name'] = $_FILES['myfile']['name'][$i];
$this->load->library('upload', $config);
$this->upload->initialize($config);
$this->upload->do_upload('file');
if($this->upload->do_upload('file')){
$file_data = $this->upload->data();
$data[$i]['gallery_id'] = $this->input->post('gallery_id');
$data[$i]['file_name'] = $file_data['file_name'];
$data[$i]['created_date'] = date('Y-m-d h:i:s');
}else{
$this->session->set_flashdata('error',$this->upload->display_errors());
redirect('MultipleFileUploadController<span style="font-size: 1rem;">'</span><span style="font-size: 1rem;">);</span>

}
}
$this->MultipleFileUploadModel->insert_data($data);
$this->session->set_flashdata('success','details has been successfully inserted !');
redirect('MultipleFileUploadController');
}
}
?>

3. Model: MultipleFileUploadModel

<?php
class MultipleFileUploadModel extends CI_Model{
function __construct(){
parent:: __construct();
}
public function insert_data($data){
$this->db->insert_batch('multiple_file_upload',$data);
}
}
?>

Thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion. if you face any issue with this code let us know. We’d love to help!

AWS SNS with Codeigniter: How to Send SMS Using AWS SNS Services in Codeigniter ?

Send Sms using AWS SNS

Amazon Simple Notification Service (SNS) is an exceedingly accessible, strong secure which enables you to build a serverless application. Serverless application enables you to build and run applications and administrations without considering servers. AWS SNS provides sevices at a very cheap price. You can check here AWS SNS pricing.

This tutorial illustrates how to send SMS using AWS services. Let see step by step how to implement this configuration.

Get Client key and Client Secret key from AWS:

Login to your aws console. here you can find the Menu “My Billing Dashboard” under profile area.Inside of Access keys (access key ID and secret access key) you need to create new access key and save it to use in future.

Installation and Configuration AWS SDK in codeigniter:

To get started, download a specific version of the zip file from https://github.com/aws/aws-sdk-php/releases, unzip it inside application/third_party directory of your codeigniter project.

Creating Base Model for Sending Email:

It is best practice to make a base model to put all send sms functionalities so that in every child model you can extend base model to avoid repetition of code.Create a file called My_Model inside application/core directory and put code below giving.Here is how code looks.

My_Model.php

<?php
require_once APPPATH.'third_party/awsSns/aws-autoloader.php';
class MY_Model extends CI_Model
{
public function SendAwsSms(){
$params = array(
'credentials'=> array(
'key'=>'YOUR API KEY',
'secret'=>'YOUR CLIENT SECRET KEY',
),
'region'=>'us-east-1',
'version'=>'latest'
);
$sns = new \Aws\Sns\SnsClient($params);
$args = array(
"SenderID"=>"SenderName",
"SMSType"=>"Transactional",
"Message"=>"Hello ! This is a test message",
"PhoneNumber"=>"Mobile No",
);
$result = $sns->publish($args);
}
}

Creating Model to Extend Base Model:

Now extend base model that already created.

<?php
  class AwsSnsModel extends My_Model {
     public function __construct() {
  }
}
?>

Creating Controller:

After done with the model, next we need to create controller and here we will load model.From controller we need to call the function that already implemented in base model. Also you can pass parameter like phone number and message to the function.

Create a file named AwsSendSmsController.phpinside application/controller directory. Please find below the code.

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class AwsSendSmsController extends CI_Controller {
publicfunction __construct(){
parent::__construct();
$this->load->model('AwsSnsModel');
}
    public function index(){
        $this->AwsSnsModel->SendAwsSms();
    }
}
Thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion. if you face any issue with this code let us know. We’d love to help!

.

phpMyAdmin: How to Import and Export Data using phpMyAdmin

In this post I would like to how can we Import or Export MySQL data using phpMyAdmin.

Topics will be covered in this tutorial:

a.) Import and Export Data.

b.) Export particular selected rows.

c.) Export rows from a particular index(Primary ID).

Import and Export Data:

To import and Export data from phpMyAdmin is very easy just you will get it on a few clicks. Just follow the steps.

To Export Database/Table:

1. Select the database or table you want to import.

Mysql database

2. Click on Export button from top menu.

Export Option in Mysql phpMyAdmin

3. Click on “Go” Button and the download will be start. Before export, custom option you can select For ex: If you want to export only data you can choose the data option so that only records will be exported from the database or table you have choosen.

To Import Database/Table:

Before Import using phpMyAdmin Some of the things you need to remember.

  • Make sure the tables is not exists into database, if the create structure you already have in sql file.
  • Make sure that the same primary key(Unique ID) records is not present in sql file which is already present into database table other wise it will produce error of duplicate entry.

Follow these simple steps to Import using phpMyAdmin.

1. Go to the database.

2. Click on Import option from top.

Import Option in phpMyAdmin

3. Choose the sql file to Import.

4. Click on Go Button. If everything is Ok, then Import will be successfully done.

Export particular selected rows:

To Export particular selected rows from database table you need to select rows you want to export. Please Find Below the screen to understand better how to achieve this.

Export Particular Selected Rows Using Phpmyadmin

Export rows from a particular index(Primary ID):

You can also export data from a particular ID of a table. By running a simple query it will be easy to get all records from a particular Id and after that you can export it.

Query: SELECT  * FROM `table_name`  WHERE id > 27

Export Data From a Particular Id

Thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion. if you face any issue with this code let us know. We’d love to help!