<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: biplab3</title>
    <description>The latest articles on DEV Community by biplab3 (@biplab3).</description>
    <link>https://dev.to/biplab3</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F890357%2F6add46aa-9432-4221-b21c-2d3b8bacd818.png</url>
      <title>DEV Community: biplab3</title>
      <link>https://dev.to/biplab3</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/biplab3"/>
    <language>en</language>
    <item>
      <title>How to use forEach loop in Node JS template engine</title>
      <dc:creator>biplab3</dc:creator>
      <pubDate>Sat, 29 Jul 2023 12:59:05 +0000</pubDate>
      <link>https://dev.to/biplab3/how-to-use-foreach-loop-in-node-js-template-engine-2gob</link>
      <guid>https://dev.to/biplab3/how-to-use-foreach-loop-in-node-js-template-engine-2gob</guid>
      <description>&lt;p&gt;Hi friends, in this tutorial you will learn how to use forEach loop in Node JS template engine. Generally, ejs (embedded template engine) is known as the node js template engine. Therefore, we will use forEach loop inside the html files residing under the views folder by default.&lt;/p&gt;

&lt;p&gt;Also read, EJS Template in Node JS with an Example&lt;/p&gt;

&lt;p&gt;HTML files are created inside the views folder with .ejs extension which means the HTML files can be displayed on the browser directly without any .html extension just by including the name of the route.&lt;/p&gt;

&lt;p&gt;Also read, How to render HTML files in Express JS&lt;/p&gt;

&lt;p&gt;Steps to use forEach loop in Node JS template engine&lt;/p&gt;

&lt;p&gt;Step 1:- First of all create a file with a .js extension inside the root directory that is your project folder. For eg:-&lt;br&gt;
foreach.js&lt;/p&gt;

&lt;p&gt;Step 2:- Now, inside the "foreach.js", initialize the packages and modules of express js framework with the help of const keyword as shown below.&lt;/p&gt;

&lt;p&gt;const express = require('express');&lt;/p&gt;

&lt;p&gt;Step 3:- Now, declare another variable "data" to use the functionality of express js modules as shown below.&lt;/p&gt;

&lt;p&gt;const data = express();&lt;/p&gt;

&lt;p&gt;Step 4:- Now, call the ejs template engine using the set() method and the above "data" variable as shown below.&lt;/p&gt;

&lt;p&gt;data.set('view engine','ejs');&lt;/p&gt;

&lt;p&gt;Step 5:- Now, set up the route name "profile" using the get() method and the above "data" variable as shown below.&lt;/p&gt;

&lt;p&gt;data.get('/profile',(req,resp)=&amp;gt;{&lt;br&gt;
   const skillset = ['C','C++','java','PHP','Node JS','Python','React JS'];&lt;br&gt;
   resp.render('profile',{skillset});&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;Please note that in the above piece of code, I have used an array of skillset=['C','C++','java','PHP','Node JS','Python','React JS'] so that it can be displayed in the HTML file using the forEach loop.&lt;/p&gt;

&lt;p&gt;Step 6:- Now, create an HTML file (profile.ejs) under the default views folder using the .ejs extension.&lt;/p&gt;

&lt;p&gt;Step 7:- Now, paste the below code inside the profile.ejs file as shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
    &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;
    &amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;
    &amp;lt;body&amp;gt;
        &amp;lt;h2&amp;gt;Welcome to the profile page&amp;lt;/h2&amp;gt;
        &amp;lt;h3&amp;gt;My Skillsets are given below&amp;lt;/h3&amp;gt;
        &amp;lt;ul&amp;gt;
            &amp;lt;% skillset.forEach((val)=&amp;gt;{
                %&amp;gt;
                    &amp;lt;li&amp;gt;&amp;lt;%= val %&amp;gt;&amp;lt;/li&amp;gt;
                &amp;lt;%
            }) %&amp;gt;
        &amp;lt;/ul&amp;gt;
    &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Complete Code (foreach.js)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const express = require('express');
const data = express();
data.set('view engine','ejs');
data.get('/profile',(req,resp)=&amp;gt;{
   const skillset = ['C','C++','java','PHP','Node JS','Python','React JS'];
   resp.render('profile',{skillset});
});
data.listen(3000);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 8:- Now, go to your browser and type &lt;a href="http://localhost:3000/profile"&gt;http://localhost:3000/profile&lt;/a&gt; and press ENTER and then you can see the output as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TqiuKc3p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5c2hwy1bx4k2weaxj1qg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TqiuKc3p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5c2hwy1bx4k2weaxj1qg.png" alt="Image description" width="430" height="237"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Conclusion:- I hope this tutorial will help you to understand the concept. If there is any doubt then please leave a comment below. Download&lt;/p&gt;

</description>
      <category>node</category>
      <category>express</category>
    </item>
    <item>
      <title>Write a file into specific folder in Node JS example</title>
      <dc:creator>biplab3</dc:creator>
      <pubDate>Fri, 19 May 2023 19:16:40 +0000</pubDate>
      <link>https://dev.to/biplab3/write-a-file-into-specific-folder-in-node-js-example-11kk</link>
      <guid>https://dev.to/biplab3/write-a-file-into-specific-folder-in-node-js-example-11kk</guid>
      <description>&lt;p&gt;Hi friends, in this tutorial you will learn how to write a file into specific folder in node js and it is a very basic concept of a node js filesystem. In order to write a file you have to follow the below steps:&lt;/p&gt;

&lt;h2&gt;
  
  
  Required steps to write a file into specific folder in Node JS
&lt;/h2&gt;

&lt;p&gt;Step 1:- Create a folder inside the node js application or anywhere you want.&lt;/p&gt;

&lt;p&gt;Step 2:- Create a file with a .js extension inside the node js application. For eg:- filesystem.js&lt;/p&gt;

&lt;p&gt;Also read, &lt;a href="https://pbphpsolutions.com/node-js-hello-world-program.html"&gt;Node Js hello world program&lt;br&gt;
&lt;/a&gt;&lt;br&gt;
Now, before writing a file, you have to include two built-in modules of node js as given below&lt;/p&gt;

&lt;p&gt;fs module:- In order to work with the filesystem such as creating a file, reading a file, updating the file, and deleting a file in node js, there is a built-in module called "fs". You can use this module with the help of require() method as shown below.&lt;/p&gt;

&lt;p&gt;const fs = require("fs");&lt;/p&gt;

&lt;p&gt;path module:- In order to get the path of a specific folder of the directory, you can include this module as shown below.&lt;/p&gt;

&lt;p&gt;const path = require("path");&lt;/p&gt;

&lt;p&gt;Step 3:- In the filesystem.js file, call the above two modules as given below.&lt;/p&gt;

&lt;p&gt;const fs = require('fs');&lt;br&gt;
const path = require('path');&lt;/p&gt;

&lt;p&gt;Step 4:- Now, get the path of the specific folder where you want to write the file using the path variable with the help of the join() method as shown below.&lt;/p&gt;

&lt;p&gt;const directory = path.join(__dirname,'your folder name');&lt;/p&gt;

&lt;p&gt;Now, if you console the above directory variable and run your node js file in the terminal then you can see the folder path as shown below&lt;/p&gt;

&lt;p&gt;D:\nodejs_tutorials\myfiles&lt;/p&gt;

&lt;p&gt;Step 5:- Next, we will create the file using the writeFileSync() function with the help of filesystem constant "fs". as given below.&lt;/p&gt;

&lt;p&gt;fs.writeFileSync(directory+"/test.txt","Hi this is a text file");&lt;/p&gt;

&lt;p&gt;Note that in the above line of code, do not forget to include the directory inside the writeFileSync() function because the file will be created inside that specific directory.&lt;/p&gt;

&lt;p&gt;Also, read, &lt;a href="https://pbphpsolutions.com/how-to-install-package-json-file-in-node-js.html"&gt;How to install package JSON file in node js&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step 6:- Now, in the VS code, open the terminal and run the node js file (filesystem.js) and you will see that the test.txt file has been created under the specific folder you mentioned at the time of directory declaration.&lt;/p&gt;

&lt;p&gt;Complete Code:- (filesystem.js)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fs = require('fs');
const path = require('path');
const directory = path.join(__dirname,'myfiles');
//console.log(directory);
fs.writeFileSync(directory+"/test.txt","Hi this is a text file");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Conclusion:- I hope this tutorial will help you to understand the concept.&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>CCAvenue Payment Gateway Integration in PHP</title>
      <dc:creator>biplab3</dc:creator>
      <pubDate>Sun, 07 May 2023 07:32:18 +0000</pubDate>
      <link>https://dev.to/biplab3/ccavenue-payment-gateway-integration-in-php-56kj</link>
      <guid>https://dev.to/biplab3/ccavenue-payment-gateway-integration-in-php-56kj</guid>
      <description>&lt;p&gt;Hi friends, in this tutorial you will learn how to do the CCAvenue payment gateway integration in PHP. CCAvenue is one of India's top payment gateways, including multiple payment options such as 200+ Mastercard, visa, Rupay, Netbanking, Wallet payments, UPI payments, etc., along with multi-currency options. &lt;/p&gt;

&lt;p&gt;This payment gateway is very fast, simple, and secure and sends the invoice as soon as the payment is done by the merchants. As we all know that we need some keys and credentials provided by the gateway provider while integrating payment gateways.&lt;/p&gt;

&lt;p&gt;Also, read, Integrate Instamojo payment gateway in PHP step by step&lt;/p&gt;

&lt;p&gt;Test and Production Environment&lt;/p&gt;

&lt;p&gt;In every payment gateway, there have to be two types of environments. One is for testing and another is for the production environment as shown below&lt;/p&gt;

&lt;p&gt;CCAvenue Test URL:  &lt;a href="https://test.ccavenue.com"&gt;https://test.ccavenue.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;CCAvenue Production URL:  &lt;a href="https://secure.ccavenue.com"&gt;https://secure.ccavenue.com&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Required steps for CCAvenue payment gateway integration in PHP
&lt;/h2&gt;

&lt;p&gt;Step 1:- Go to the CCAvenue website and sign up for a Merchant account here as shown in the below screenshot.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B4bWUYgK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/upk055yrlml1g94nbzdh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B4bWUYgK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/upk055yrlml1g94nbzdh.png" alt="Image description" width="661" height="595"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, provide your business details and bank details, and KYC to proceed and you will receive an email for account details.&lt;/p&gt;

&lt;p&gt;Step 2:- Now, log in to your CCAvenue Merchant account and click on web integration kit under the resources tab.&lt;/p&gt;

&lt;p&gt;Step 3:- On the left side, click on download integration kits and download the PHP kit as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gsJi4Mup--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/efjgp6z9z1a5si4kgy87.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gsJi4Mup--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/efjgp6z9z1a5si4kgy87.png" alt="Image description" width="709" height="459"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step 4:- Now, unzip the downloaded file and you will see three types of kits as given below&lt;/p&gt;

&lt;p&gt;. CUSTOM_CHECKOUT_FORM_KIT&lt;br&gt;
. IFRAME_KIT&lt;br&gt;
. NON_SEAMLESS_KIT&lt;/p&gt;

&lt;p&gt;We will go with the IFRAME_KIT.&lt;/p&gt;

&lt;p&gt;Step 5:- Now, put this IFRAME_KIT folder inside the root directory of your local server which means WAMP, XAMPP, etc.&lt;/p&gt;

&lt;p&gt;Step 6:- Get the API keys from the settings tab in your Merchant dashboard as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fL89o3-h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f14ujis6lsk5wjtmtafi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fL89o3-h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f14ujis6lsk5wjtmtafi.png" alt="Image description" width="800" height="369"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step 7:- Open the dataFrom.htm file and modify it as given below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;!-- Bootstrap CSS --&amp;gt;
&amp;lt;link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"&amp;gt;
&amp;lt;script&amp;gt;
    window.onload = function() {
        var d = new Date().getTime();
        document.getElementById("tid").value = d;
    };
&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;form method="post" name="customerData" action="ccavRequestHandler.php"&amp;gt;
        &amp;lt;h3 class="text-center"&amp;gt;CC Avenue Payment Gateway Integration in PHP&amp;lt;/h3&amp;gt;
        &amp;lt;!-- &amp;lt;table width="40%" height="100" border='1' align="center"&amp;gt;&amp;lt;caption&amp;gt;&amp;lt;font size="4" color="blue"&amp;gt;&amp;lt;b&amp;gt;Integration Kit&amp;lt;/b&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/caption&amp;gt;&amp;lt;/table&amp;gt; --&amp;gt;
        &amp;lt;div class="container"&amp;gt;
            &amp;lt;div class="row"&amp;gt;
                &amp;lt;div class="col-sm-12"&amp;gt;
                    &amp;lt;table class="table table-bordered"&amp;gt;
                        &amp;lt;tr class="bg-dark text-white"&amp;gt;
                            &amp;lt;td colspan="2"&amp;gt; Payment Details&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr style="display: none;"&amp;gt;
                            &amp;lt;td&amp;gt;TID :&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type="text" class="form-control form-control-sm" name="tid" id="tid" readonly /&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr style="display: none;"&amp;gt;
                            &amp;lt;td&amp;gt;Merchant Id :&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type="text" class="form-control form-control-sm" name="merchant_id" value="your merchant id"/&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr style="display: none;"&amp;gt;
                            &amp;lt;td&amp;gt;Order Id    :&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type="text" class="form-control form-control-sm" name="order_id" value="123654789"/&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td&amp;gt;Amount  :&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type="text" class="form-control form-control-sm" name="amount" value="1.00"/&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr style="display: none;"&amp;gt;
                            &amp;lt;td&amp;gt;Currency    :&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type="text" class="form-control form-control-sm" name="currency" value="INR"/&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr style="display: none;"&amp;gt;
                            &amp;lt;td&amp;gt;Redirect URL    :&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type="text" class="form-control form-control-sm" name="redirect_url" value="http://localhost/myprojects/ccavenue/IFRAME_KIT/ccavResponseHandler.php"/&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr style="display: none;"&amp;gt;
                            &amp;lt;td&amp;gt;Cancel URL  :&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type="text" class="form-control form-control-sm" name="cancel_url" value="http://localhost/IFrame_PHP_kit/ccavResponseHandler.php"/&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr style="display: none;"&amp;gt;
                            &amp;lt;td&amp;gt;Language    :&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type="text" class="form-control form-control-sm" name="language" value="EN"/&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td colspan="2" class="fw-bold"&amp;gt;Billing information(optional):&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td&amp;gt;Billing Name    :&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type="text" class="form-control form-control-sm" name="billing_name" value="Charli"/&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td&amp;gt;Billing Address :&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type="text" class="form-control form-control-sm" name="billing_address" value="Room no 1101, near Railway station Ambad"/&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td&amp;gt;Billing City    :&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type="text" class="form-control form-control-sm" name="billing_city" value="Indore"/&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td&amp;gt;Billing State   :&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type="text" class="form-control form-control-sm" name="billing_state" value="MP"/&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td&amp;gt;Billing Zip :&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type="text" class="form-control form-control-sm" name="billing_zip" value="425001"/&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td&amp;gt;Billing Country :&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type="text" class="form-control form-control-sm" name="billing_country" value="India"/&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td&amp;gt;Phone Number    :&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type="text" class="form-control form-control-sm" name="billing_tel" value="9876543210"/&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td&amp;gt;Email   :&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type="text" class="form-control form-control-sm" name="billing_email" value="test@test.com"/&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr style="display: none;"&amp;gt;
                            &amp;lt;td&amp;gt;Integration Type    :&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type="text" class="form-control form-control-sm" name="integration_type" value="iframe_normal"/&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;INPUT TYPE="submit" class="btn btn-dark btn-sm" value="CheckOut"&amp;gt;&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                    &amp;lt;/table&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/form&amp;gt;
&amp;lt;script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above file, put the merchant id received from the API keys section. Please note that your access code and working key should be different for testing purposes and the merchant id will be the same. For the test environment, you should send an email to the support team of CCAvenue at &lt;a href="mailto:support@ccavenue.com"&gt;support@ccavenue.com&lt;/a&gt; to activate the test environment. &lt;/p&gt;

&lt;p&gt;After the activation, you will be able to use the CCAvenue testing payment gateway interface. If you run the above file in your local server then you will see the output on the browser as given below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lu0ngZG9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m2vrik9uzlh95ftt4exi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lu0ngZG9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m2vrik9uzlh95ftt4exi.png" alt="Image description" width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step 8:- Now, open the ccavRequestHandler.php and put the access code, working key, and merchant data shared by CCAvenue, and change the production URL as given below.&lt;/p&gt;

&lt;p&gt;$production_url='&lt;a href="https://test.ccavenue.com/transaction/transaction.do?command=initiateTransaction&amp;amp;encRequest='.%24encrypted_data.'&amp;amp;access_code='.%24access_code"&gt;https://test.ccavenue.com/transaction/transaction.do?command=initiateTransaction&amp;amp;encRequest='.$encrypted_data.'&amp;amp;access_code='.$access_code&lt;/a&gt;;&lt;/p&gt;

&lt;p&gt;Step 9:- Open ccavResponseHandler.php and put in the working key you received from CCAvenue as shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php include('Crypto.php')?&amp;gt;
&amp;lt;?php

    error_reporting(0);

    $workingKey='working key';      //Working Key should be provided here.
    $encResponse=$_POST["encResp"];     //This is the response sent by the CCAvenue Server
    $rcvdString=decrypt($encResponse,$workingKey);      //Crypto Decryption used as per the specified working key.
    $order_status="";
    $decryptValues=explode('&amp;amp;', $rcvdString);
    $dataSize=sizeof($decryptValues);
    echo "&amp;lt;center&amp;gt;";
    for($i = 0; $i &amp;lt; $dataSize; $i++) 
    {
        $information=explode('=',$decryptValues[$i]);

        if($i==3)   $order_status=$information[1];

    }

    if($order_status==="Success")
    {
        echo "&amp;lt;br&amp;gt;&amp;lt;b&amp;gt;Thank you for shopping with us. Your credit card has been charged and your transaction is successful. We will be shipping your order to you soon.&amp;lt;a href='http://localhost/myprojects/ccavenue/IFRAME_KIT/dataFrom.htm'&amp;gt;Back To Order Page&amp;lt;/a&amp;gt;&amp;lt;/b&amp;gt;";

    }
    else if($order_status==="Aborted")
    {
        echo "&amp;lt;br&amp;gt;&amp;lt;b&amp;gt;Thank you for shopping with us.We will keep you posted regarding the status of your order through e-mail&amp;lt;/b&amp;gt;";

    }
    else if($order_status==="Failure")
    {
        echo "&amp;lt;br&amp;gt;&amp;lt;b&amp;gt;Thank you for shopping with us.However,the transaction has been declined.&amp;lt;/b&amp;gt;";
    }
    else
    {
        echo "&amp;lt;br&amp;gt;&amp;lt;b&amp;gt;Security Error. Illegal access detected&amp;lt;/b&amp;gt;";

    }

    echo "&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;";

    //print_r($dataSize);

     echo "&amp;lt;table cellspacing=4 cellpadding=4&amp;gt;";
     for($i = 0; $i &amp;lt; $dataSize; $i++) 
     {
        $information=explode('=',$decryptValues[$i]);
            echo '&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;'.$information[0].'&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;'.$information[1].'&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;';
     }

     echo "&amp;lt;/table&amp;gt;&amp;lt;br&amp;gt;";
     echo "&amp;lt;/center&amp;gt;";
?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 10:- Please do not forget to include the Crypto.php file in both the ccavRequestHandler.php and ccavResponseHandler.php as included because it encrypts the payment request sent to the bank and returns the response from the bank with the help of the decrypt() function. The Crypto.php file contains the below functions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php
/*
* @param1 : Plain String
* @param2 : Working key provided by CCAvenue
* @return : Decrypted String
*/
function encrypt($plainText,$key)
{
    $key = hextobin(md5($key));
    $initVector = pack("C*", 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
    $openMode = openssl_encrypt($plainText, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $initVector);
    $encryptedText = bin2hex($openMode);
    return $encryptedText;
}

/*
* @param1 : Encrypted String
* @param2 : Working key provided by CCAvenue
* @return : Plain String
*/
function decrypt($encryptedText,$key)
{
    $key = hextobin(md5($key));
    $initVector = pack("C*", 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
    $encryptedText = hextobin($encryptedText);
    $decryptedText = openssl_decrypt($encryptedText, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $initVector);
    return $decryptedText;
}

function hextobin($hexString) 
 { 
    $length = strlen($hexString); 
    $binString="";   
    $count=0; 
    while($count&amp;lt;$length) 
    {       
        $subString =substr($hexString,$count,2);           
        $packedString = pack("H*",$subString); 
        if ($count==0)
        {
            $binString=$packedString;
        } 

        else 
        {
            $binString.=$packedString;
        } 

        $count+=2; 
    } 
        return $binString; 
  } 
?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 11:- After submission of consumer checkout, as shown above in step 7, you will see the CCAvenue payment interface as given below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---SbM9kBj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mpcjysxuuo6brw77l9g6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---SbM9kBj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mpcjysxuuo6brw77l9g6.png" alt="Image description" width="463" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, select any of the payment methods and make payment and you will see the payment response as given below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZqcunDbo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6oq39q7diy8slnn6un2y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZqcunDbo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6oq39q7diy8slnn6un2y.png" alt="Image description" width="800" height="202"&gt;&lt;/a&gt;&lt;br&gt;
Step 12:- Now, click on return to merchant site as shown in the above screenshot and you will see the response as given below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Spa5Fq33--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7bn08yrou61kvhspd5im.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Spa5Fq33--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7bn08yrou61kvhspd5im.png" alt="Image description" width="800" height="423"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, the integration is done.&lt;/p&gt;

&lt;p&gt;Also read, Razorpay payment gateway integration in PHP&lt;/p&gt;

&lt;p&gt;Now, if you want to save the transaction details in the MySQL database then follow the below steps.&lt;/p&gt;

&lt;p&gt;Establish the database connection as given below.&lt;br&gt;
&lt;strong&gt;dbconnect.php&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php
$servername='localhost';
$username="root";
$password="";
try
{
    $con=new PDO("mysql:host=$servername;dbname=php_db",$username,$password);
    $con-&amp;gt;setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
    //echo 'connected';
}
catch(PDOException $e)
{
    echo '&amp;lt;br&amp;gt;'.$e-&amp;gt;getMessage();
}
?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a table in your MySQL database as given below.&lt;/p&gt;

&lt;p&gt;DDL information of the table&lt;/p&gt;

&lt;p&gt;CREATE TABLE IF NOT EXISTS ccavenue_transaction_details (&lt;br&gt;
id int NOT NULL AUTO_INCREMENT,&lt;br&gt;
order_id varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,&lt;br&gt;
tracking_id varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,&lt;br&gt;
bank_ref_no varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,&lt;br&gt;
order_status varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,&lt;br&gt;
failure_message varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,&lt;br&gt;
payment_mode varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,&lt;br&gt;
status_message varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,&lt;br&gt;
currency text COLLATE utf8mb4_unicode_ci NOT NULL,&lt;br&gt;
amount varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,&lt;br&gt;
billing_tel varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,&lt;br&gt;
billing_email varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,&lt;br&gt;
transaction_date varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,&lt;br&gt;
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,&lt;br&gt;
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,&lt;br&gt;
PRIMARY KEY (id)&lt;br&gt;
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;&lt;/p&gt;

&lt;p&gt;Open the ccavResponseHandler.php and modify the file as given below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php include('Crypto.php')?&amp;gt;
&amp;lt;?php include ('dbconnect.php');?&amp;gt;
&amp;lt;?php
    error_reporting(0);

    $workingKey='working key';      //Working Key should be provided here.
    $encResponse=$_POST["encResp"];     //This is the response sent by the CCAvenue Server
    $rcvdString=decrypt($encResponse,$workingKey);      //Crypto Decryption used as per the specified working key.
    $order_status="";
    $decryptValues=explode('&amp;amp;', $rcvdString);
    $dataSize=sizeof($decryptValues);
    for($i = 0; $i &amp;lt; $dataSize; $i++) 
    {
        $information=explode('=',$decryptValues[$i]);
        if($i==3)   $order_status=$information[1];
        if($i==0)   $order_id=$information[1];
        if($i==1)   $tracking_id=$information[1];
        if($i==2)   $bank_ref_no=$information[1];
        if($i==4)   $failure_message=$information[1];
        if($i==5)   $payment_mode=$information[1];
        if($i==8)   $status_message=$information[1];
        if($i==9)   $currency=$information[1];
        if($i==10)  $amount=$information[1];
        if($i==17)  $billing_tel=$information[1];
        if($i==18)  $billing_email=$information[1];
        if($i==40)  $transaction_date=$information[1];

    }

    if($order_status==="Success")
    {
        echo "&amp;lt;br&amp;gt;&amp;lt;b&amp;gt;Thank you for shopping with us. Your credit card has been charged and your transaction is successful. We will be shipping your order to you soon.&amp;lt;a href='http://localhost/myprojects/ccavenue/IFRAME_KIT/dataFrom.htm'&amp;gt;Back To Order Page&amp;lt;/a&amp;gt;&amp;lt;/b&amp;gt;";

        //insert data into mysql database
         $sql = "INSERT INTO ccavenue_transaction_details(order_id,tracking_id,bank_ref_no,order_status,failure_message,payment_mode,status_message,currency,amount,billing_tel,billing_email,transaction_date) values('$order_id','$tracking_id','$bank_ref_no','$order_status','$failure_message','$payment_mode','$status_message','$currency','$amount','$billing_tel','$billing_email','$transaction_date')";
         $stmt = $con-&amp;gt;prepare($sql);
         $stmt-&amp;gt;execute();

    }
    else if($order_status==="Aborted")
    {
        echo "&amp;lt;br&amp;gt;&amp;lt;b&amp;gt;Thank you for shopping with us.We will keep you posted regarding the status of your order through e-mail&amp;lt;/b&amp;gt;";

    }
    else if($order_status==="Failure")
    {
        echo "&amp;lt;br&amp;gt;&amp;lt;b&amp;gt;Thank you for shopping with us.However,the transaction has been declined.&amp;lt;/b&amp;gt;";
    }
    else
    {
        echo "&amp;lt;br&amp;gt;&amp;lt;b&amp;gt;Security Error. Illegal access detected&amp;lt;/b&amp;gt;";

    }

    echo "&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;";
?&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above file, you have noticed that if the order status is a success then you can insert the transaction-related data such as order id, tracking id, bank ref number and payment mode, etc. in your database.&lt;/p&gt;

&lt;p&gt;Conclusion:- I hope this tutorial will help you to understand the concept. If there is any doubt then please leave a comment below.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>php</category>
      <category>paymentgateway</category>
      <category>ccavenue</category>
    </item>
    <item>
      <title>Remove last character from javascript string</title>
      <dc:creator>biplab3</dc:creator>
      <pubDate>Thu, 02 Feb 2023 15:30:48 +0000</pubDate>
      <link>https://dev.to/biplab3/remove-last-character-from-javascript-string-1egd</link>
      <guid>https://dev.to/biplab3/remove-last-character-from-javascript-string-1egd</guid>
      <description>&lt;p&gt;There are two methods given below by which you can remove last character from javascript string.&lt;/p&gt;

&lt;p&gt;slice():- This method is used to cut a part of the string and return that part as a new string. This method takes two parameters as the start position and the end position. In javascript, the position starts from zero. &lt;/p&gt;

&lt;p&gt;Syntax:-&lt;/p&gt;

&lt;p&gt;slice(start position index, end position index)&lt;/p&gt;

&lt;p&gt;Also read, Javascript String Methods with example&lt;/p&gt;

&lt;p&gt;Below is an example to remove last character from javascript string&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1"&amp;gt;
    &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
   &amp;lt;h3&amp;gt;Remove the last cahracter from a string in Javscript&amp;lt;/h3&amp;gt;
   &amp;lt;input type="text" id="rmv"&amp;gt;
   &amp;lt;button type="button" onclick="getString()"&amp;gt;Remove&amp;lt;/button&amp;gt;
   &amp;lt;p&amp;gt;&amp;lt;b&amp;gt;Result:&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;
   &amp;lt;p id="res"&amp;gt;&amp;lt;/p&amp;gt;
   &amp;lt;script type="text/javascript"&amp;gt;
    function getString(){
        var string = document.getElementById('rmv').value;
        alert(string);
        let new_string = string.slice(0,-1);
        document.getElementById('res').innerHTML = new_string;
    }
   &amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8gpyov60hk7iq16m4jjs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8gpyov60hk7iq16m4jjs.png" alt="Image description" width="451" height="146"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Explanation of the code:-&lt;/p&gt;

&lt;p&gt;In the above example, you have noticed that zero is taken as the first parameter inside the slice() function, and -1 is taken as the second parameter because index position -1 is considered as the last character. &lt;/p&gt;

&lt;p&gt;So, you must know that the slice() function returns the extracted string except for the last character. That is why the slice() function helps us to remove the last character.&lt;/p&gt;

&lt;p&gt;substr():- This function also extracts a part of the string and returns the extracted part as the new string depending on its arguments and it takes two arguments. The first argument is the index number of the first position i.e. start position and the second argument is the total length of the string. &lt;/p&gt;

&lt;p&gt;The substr() is similar to the slice() function but the only difference is, it takes the second argument as the length of the string instead of the end position index.&lt;/p&gt;

&lt;p&gt;Syntax:-&lt;/p&gt;

&lt;p&gt;substr(start position index, length)&lt;/p&gt;

&lt;p&gt;Below is an example of substr() function:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1"&amp;gt;
    &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
   &amp;lt;h3&amp;gt;Remove the last cahracter from a string in Javscript&amp;lt;/h3&amp;gt;
   &amp;lt;input type="text" id="rmv"&amp;gt;
   &amp;lt;button type="button" onclick="getString()"&amp;gt;Remove&amp;lt;/button&amp;gt;
   &amp;lt;p&amp;gt;&amp;lt;b&amp;gt;Result:&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;
   &amp;lt;p id="res"&amp;gt;&amp;lt;/p&amp;gt;
   &amp;lt;script type="text/javascript"&amp;gt;
    function getString(){
        var string = document.getElementById('rmv').value;
        let new_string = string.substr(0,string.length-1);
        document.getElementById('res').innerHTML = new_string;
    }
   &amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:-  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkv4mt6a2i5hvkc7181gi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkv4mt6a2i5hvkc7181gi.png" alt="Image description" width="451" height="146"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Explanation of the code:-&lt;/p&gt;

&lt;p&gt;In the above example, you have noticed that I have taken the first argument as the index number of the first position which is 0 and the second argument is a string.length-1. For example, if a string contains a length of 5 then string.length-1 gives us 4 as the string length which means the last character is ignored. Finally, we have removed the last character.&lt;/p&gt;

&lt;p&gt;Conclusion:- I hope this tutorial will help you to understand the concept. If there is any doubt then please leave a comment below&lt;/p&gt;

</description>
      <category>crypto</category>
      <category>cryptocurrency</category>
      <category>blockchain</category>
      <category>web3</category>
    </item>
    <item>
      <title>Factorial Program in PHP with example</title>
      <dc:creator>biplab3</dc:creator>
      <pubDate>Sat, 19 Nov 2022 07:07:15 +0000</pubDate>
      <link>https://dev.to/biplab3/factorial-program-in-php-with-example-5g6l</link>
      <guid>https://dev.to/biplab3/factorial-program-in-php-with-example-5g6l</guid>
      <description>&lt;p&gt;Hi friends, in this tutorial, you will learn how to run the factorial program in PHP. I will explain the details in a step-by-step process. This is a very simple program and you will never forget it if you read this article once.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Also, read the &lt;a href="https://pbphpsolutions.com/oops-concepts-in-php-with-realtime-examples.html" rel="noopener noreferrer"&gt;OOPs concept in PHP with real-time examples&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps to writing the factorial program in PHP
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1:-&lt;/strong&gt; First of all, enter the input value in the HTML form.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:-&lt;/strong&gt; Now, we will receive the input value with the help of $_POST superglobal variable for which the factorial will be calculated.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:-&lt;/strong&gt; Next, we will declare some variables as shown below&lt;/p&gt;

&lt;p&gt;$fact = "";&lt;br&gt;
$factorial_number_err = "";&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4:-&lt;/strong&gt; Now, we will check if the input value is not empty then we will run a for loop up to the number we have received from the HTML form.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5:-&lt;/strong&gt; Now, each of the incremented values of the for loop will be multiplied with the $fact variable in every iteration and store the result in the $fact variable as shown below&lt;/p&gt;

&lt;p&gt;Suppose you have to find a factorial of 5, then the for loop will be executed up to 5.&lt;/p&gt;

&lt;p&gt;For '1', the value of the fact variable will be fact = fact*1 i.e. fact = 1*1 and it becomes face = 1;&lt;/p&gt;

&lt;p&gt;For '2', the value of the fact variable will be fact = fact*2 i.e. fact = 1*2 and it becomes fact = 2;&lt;/p&gt;

&lt;p&gt;For '3', the value of the fact variable will be fact = fact*3 i.e. fact = 2*3 and it becomes fact = 6;&lt;/p&gt;

&lt;p&gt;For '4', the value of the fact variable will be fact = fact*4 i.e. fact = 6*4 and it becomes fact = 24;&lt;/p&gt;

&lt;p&gt;For '5', the value of the fact variable will be fact = fact*5 i.e. fact = 24*5 and it becomes fact = 120&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6:-&lt;/strong&gt; From the above step, you can see that the final factorial value of the entered number is 120.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Complete Code:-&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

    $factorial_number_err = "";
    $fact = "";

    if(isset($_POST['save']))
    {

        if(!empty($_POST['fact_number']))
        {
            $factorial_number = $_POST['fact_number'];

            $fact = 1;
            for($i = 1; $i&amp;lt;=$factorial_number; $i++)
            {
                $fact = $i*$fact; 

            }
        }
        else{
            $factorial_number_err = "Input is missing !";
            $fact = "";
        }
    }
 ?&amp;gt;
 &amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;title&amp;gt;Factorial Example&amp;lt;/title&amp;gt;
  &amp;lt;meta charset="utf-8"&amp;gt;
  &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1"&amp;gt;
  &amp;lt;link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/css/bootstrap.min.css" rel="stylesheet"&amp;gt;
  &amp;lt;script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.bundle.min.js"&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;style type="text/css"&amp;gt;
    .container{
        width: 40%;
    }
  &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;div class="container mt-3"&amp;gt;
  &amp;lt;h2&amp;gt;Factorial program in PHP&amp;lt;/h2&amp;gt;
  &amp;lt;form action="" method="post"&amp;gt;
    &amp;lt;div class="mb-3 mt-3"&amp;gt;
      &amp;lt;label for="email" class="fw-bold"&amp;gt;Please enter the number:&amp;lt;/label&amp;gt;
      &amp;lt;input type="number" class="form-control" id="email" placeholder="Enter The Number" name="fact_number"&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;button type="submit" class="btn btn-primary" name="save"&amp;gt;Submit&amp;lt;/button&amp;gt;
  &amp;lt;/form&amp;gt;
  &amp;lt;br&amp;gt;
  &amp;lt;p style="color: red;" class="fw-bold"&amp;gt;&amp;lt;?php echo $factorial_number_err; ?&amp;gt;&amp;lt;/p&amp;gt;
    &amp;lt;?php
        if($fact!=""){
            echo '&amp;lt;p style="color: red;" class="fw-bold"&amp;gt;The factorial of the given number is: '.$fact.'&amp;lt;/p&amp;gt;';
        }
    ?&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion:-&lt;/strong&gt; I hope this tutorial will help you to understand the concept. If there is any doubt then please leave a comment below.&lt;/p&gt;

</description>
      <category>gratitude</category>
    </item>
    <item>
      <title>How to Import Custom Module in Node JS</title>
      <dc:creator>biplab3</dc:creator>
      <pubDate>Sat, 19 Nov 2022 06:59:21 +0000</pubDate>
      <link>https://dev.to/biplab3/how-to-import-custom-module-in-node-js-434d</link>
      <guid>https://dev.to/biplab3/how-to-import-custom-module-in-node-js-434d</guid>
      <description>&lt;p&gt;Hi friends, in this tutorial, you will learn how to import a custom module in Node JS. Before getting started with the custom module, you must know what the module means in node js and how to include that module before creating any object. A module is nothing but a javascript function or a library. &lt;/p&gt;

&lt;p&gt;Also, there are built-in modules and you can directly invoke those modules with the help of require() function by assigning them to a javascript variable. As I already discussed one of the built-in modules (http) and how to use it. So, I will explain the custom module in a step-by-step process.&lt;/p&gt;

&lt;p&gt;Also read, &lt;strong&gt;&lt;a href="https://pbphpsolutions.com/node-js-http-server-example.html"&gt;the Node JS HTTP server example&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Three steps to import custom module in Node JS
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create a javascript file where the main node js file is located.&lt;/li&gt;
&lt;li&gt;Declare a function or more than one function in that javascript file.&lt;/li&gt;
&lt;li&gt;Invoke that external JS file in the main node JS file using the required function as shown below.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*&lt;em&gt;var random = require('./random.js');&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
Please note that random.js is assigned to a variable 'random'. Later on, we will use this random variable to call the functions executed in the random.js file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;random.js&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exports.getRandom = function(){
       return Math.floor((Math.random()*10)+1);
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the random.js file, there is a function called getRandom() which returns a whole random number between 1 to 10 every time you initiate the main node js file in your browser.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;main.js:-&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var http = require('http');
var random = require('./random.js');

http.createServer(function (req, res){
    res.writeHead(200, {'Content-Type': 'text/html'});
    res.write("This is the random number every time you hit the browser.       "+random.getRandom());
    res.end();
}).listen(8080);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above file, you have noticed that I have included two modules inside the require() function. One is built-in module (http) and the other is random.js.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;http module is used to transfer data over the hypertext transfer protocol which means over the web browser.&lt;/li&gt;
&lt;li&gt;random.js is used to print random numbers.&lt;/li&gt;
&lt;li&gt;createServer() object is created using the http so that the response is returned from the server.&lt;/li&gt;
&lt;li&gt;When we call the getRandom() function using the random variable inside the server object, we will get the random numbers from the server each time the request is sent from the browser.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you hit &lt;a href="http://localhost:8000"&gt;http://localhost:8000&lt;/a&gt; from your browser, you will see the below output&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;This is the random number every time you hit the browser. 3&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
Conclusion:- I wish this tutorial will help you to understand the concept of importing a custom module. If there is any doubt then please leave a comment below.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>http</category>
      <category>webdev</category>
      <category>node</category>
    </item>
    <item>
      <title>Node JS HTTP server example</title>
      <dc:creator>biplab3</dc:creator>
      <pubDate>Thu, 17 Nov 2022 11:42:50 +0000</pubDate>
      <link>https://dev.to/biplab3/node-js-http-server-example-2ccf</link>
      <guid>https://dev.to/biplab3/node-js-http-server-example-2ccf</guid>
      <description>&lt;p&gt;Hi friends, in this tutorial, you will learn how to create a Node JS HTTP server. Before getting started with the HTTP server creation, you must know that HTTP is a built-in module in node js, and a module in node js acts like a javascript function or library. By using this HTTP module, we can transfer the data over the web browser.&lt;/p&gt;

&lt;p&gt;To include a module in node js, we can do so with the help of require() as shown below&lt;/p&gt;

&lt;p&gt;var http = require('http');&lt;/p&gt;

&lt;p&gt;whereas&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;http inside require is the name of the module and&lt;/li&gt;
&lt;li&gt;http with var is the object reference variable which will be used later to create the server object or any other object etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Create a Node JS HTTP server object
&lt;/h2&gt;

&lt;p&gt;When you create a node js HTTP server object then the node js file acts like a web server and listens to the server port such as 8080 for localhost etc and gives the response to the browser or client.&lt;/p&gt;

&lt;p&gt;Below is an example:- (test.js)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var http = require('http');

http.createServer(function (req, res) {
   res.writeHead(200, {'Content-Type': 'text/html'});
   res.end('Hi this is my first program in node js');
 }).listen(8080);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;Explanation of the above code:-&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
On the above code, you have noticed that the function inside the createServer() is added with port listen(8080) that means if you type &lt;a href="http://locahost:8080"&gt;http://locahost:8080&lt;/a&gt; in your browser then the browser will return the function executed written inside the createServer(). Save the above javascript code with the .js extension.&lt;/p&gt;

&lt;p&gt;Also read, &lt;strong&gt;&lt;a href="https://pbphpsolutions.com/text-slideshow-html-with-images-using-w3-css-and-javascript.html"&gt;Text slideshow HTML with images using w3 CSS and javascript&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Run the node js file using the terminal
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;open the command terminal of your computer and go to the path or location where the JavaScript file is stored.&lt;/li&gt;
&lt;li&gt; write node filname.js and press enter.&lt;/li&gt;
&lt;li&gt; Now, open the browser and hit the URL &lt;a href="http://localhost:8080"&gt;http://localhost:8080&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; Now the file will be executed and the result will be displayed to the browser.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:-&lt;/strong&gt; I hope this tutorial will help you to understand the concept. If there is any doubt then please leave a comment below.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>http</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
