Woocommerce – pagination on product reviews does not work with a custom query

I have a custom single-product-reviews.php template. On our website we use Weglot (similar to WPML) but you need to modify queries on your own to get the right reviews foreach language. If you dont the reviews are shown for the all languages for product. This is what we don’t want to have.

We have modified the query to get only the reviews for selected product and current language. This works fine. Now the problem is that the pagination is not working. It displays pages for all reviews and when you switch page you get the same reviews for each page.

enter image description here

The same reviews on each page and total number of pages = 45 even when I have in query only 173 reviews filtered by 10 per page = 18 pages not 45

Code parts are here

global $product;
$product_id = $product->get_id();
$average_rating = $product->get_average_rating();
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$number = 10;
$offset = ( $paged - 1 ) * $number;

if ( ! comments_open() ) {
    return;
}
if(weglot_get_current_language()=='cs'){
       $args = array(
       'meta_key' => 'jazyk',
       'meta_value' => 'cz',
       'post__in' => [get_queried_object_id()],
       'number' => $number,
       'offset' => $offset,
       'paged' => $paged
    );
    }
    if(weglot_get_current_language()=='sk'){
       $args = array(
       'meta_key' => 'jazyk',
       'meta_value' => 'sk',
       'post__in' => [get_queried_object_id()],
       'number' => $number,
       'offset' => $offset,
       'paged' => $paged
    );
    }
    if(weglot_get_current_language()=='hu'){
       $args = array(
       'meta_key' => 'jazyk',
       'meta_value' => 'hu',
       'post__in' => [get_queried_object_id()],
       'number' => $number,
       'offset' => $offset,
       'paged' => $paged
    );
    }
    if(weglot_get_current_language()=='ro'){
       $args = array(
       'meta_key' => 'jazyk',
       'meta_value' => 'ro',
       'post__in' => [get_queried_object_id()],
       'number' => $number,
       'offset' => $offset,
       'paged' => $paged
    );
    }
    
    // The Query
    
    //global $wp_query;
    //return $wp_query->get_queried_object_id();
    $comments_query = new WP_Comment_Query;
    $comments = $comments_query->query( $args );
    
    //count
    $args = array(
    'type' => 'review',
    'count' => true,
    'meta_key' => 'jazyk',
    'meta_value' => 'sk',
    'post__in' => [get_queried_object_id()],
    );
    $count = get_comments($args);

HTML part

<?php 

echo custom_woo_reviews_summary($product_id); ?>
<div id="reviews" class="woocommerce-Reviews">
    <div id="comments">
        <h2 class="woocommerce-Reviews-title">
            <?php
            //$count = $product->get_review_count($args);
            if ( $count && wc_review_ratings_enabled() ) {
                /* translators: 1: reviews count 2: product name */
                $reviews_title = sprintf( esc_html( _n( '%1$s review for %2$s', '%1$s reviews for %2$s', $count, 'woocommerce' ) ), esc_html( $count ), '<span>' . get_the_title() . '</span>' );
                echo apply_filters( 'woocommerce_reviews_title', $reviews_title, $count, $product ); // WPCS: XSS ok.
            } else {
                esc_html_e( 'Reviews', 'woocommerce' );
            }
            
?>
        </h2>

        <?php 
        if ( have_comments($comments) ) : ?>
            <ol class="commentlist">
                <?php wp_list_comments( apply_filters( 'woocommerce_product_review_list_args', array( 'callback' => 'woocommerce_comments' ) ) ); ?>
            </ol>

            <?php
            if ( $comments > 1  ) :
                echo '<nav class="woocommerce-pagination">';
                paginate_comments_links(
                    apply_filters(
                        'woocommerce_comment_pagination_args',
                        array(
                            'prev_text' => is_rtl() ? '&rarr;' : '&larr;',
                            'next_text' => is_rtl() ? '&larr;' : '&rarr;',
                            'type'      => 'list',
                        )
                    )
                );
                echo '</nav>';
            endif;
            ?>
        <?php else : ?>
            <p class="woocommerce-noreviews"><?php esc_html_e( 'There are no reviews yet.', 'woocommerce' ); ?></p>
        <?php endif; ?>
    </div>

Thank you in advice for your ideas.

How to ser Ltree array set php?

REQUEST

$array = [
   [
    "hierarchy" => "1",
   ],
   [
    "hierarchy" => "1.1",
   ],
   [
    "hierarchy" => "1.1.1",
   ],
   [
    "hierarchy" => "1.1.2",
   ],
   [
    "hierarchy" => "1.2",
   ],
   [
    "hierarchy" => "1.2.1",
   ],
   [
    "hierarchy" => "1.2.2",
   ],
   [
    "hierarchy" => "2",
   ],
   [
    "hierarchy" => "2.1",
   ],
   [
    "hierarchy" => "2.2",
   ],
   [
    "hierarchy" => "3.1.1",
   ],
   [
    "hierarchy" => "3.1.1.1",
   ]
];

I WANT THIS TYPE OF RESPONSE

[
  {
    "hierarchy": "1",
    "children": [
      {
        "hierarchy": "1.1",
        "children": [
          {
            "hierarchy": "1.1.1"
          },
          {
            "hierarchy": "1.1.2"
          }
        ]
      },
      {
        "hierarchy": "1.2",
         "children": [
          {
            "hierarchy": "1.2.1"
          },
          {
            "hierarchy": "1.2.2"
          }
        ]
      }
    ],
    "hierarchy": "2",
    "children": [
      {
        "hierarchy": "2.1"
      },
      {
        "hierarchy": "2.2"
      }
    ],
    "hierarchy": "3.1.1",
    "children": [
      {
        "hierarchy": "3.1.1",
      }
        ]
      },
  }
]

WordPress run php-script that adds dynamic shortcodes to a page before load

I have a script that loops through a JSON-datafile and from that file creates dynamically shortcodes that I want to be loaded in a spesific WordPress page. The script loads different JSON-files depending on the logged in users ID.

the shortcodes look like this after processing:

[woocommerce_product_documents product_sku="70.2991" title="nozzle for Adheseal"]
[woocommerce_product_documents product_sku="70.0900" title="Spraygun Multiflexcoating"]
[woocommerce_product_documents product_sku="70.2901" title="Spraygun Nozzle Coating."]

When manually added to a WP page the shortcodes are executed as normal. What I am trying to figure out is how to add/update the page dynamically, when the customer requests it. a.k.a run the script and get updated information from the JSON-file.

I know I can set a condition for the script to run on spesific conditions. But I haven’t figured out how to make WP execute the shortcodes before the page is loaded. as if they were already there ?

If there is an answer to this question somewhere that I have missed, please send me a link.
Thank you for your help.

I want to upload multiple file to sever using flutter and php, but only one file is being uploaded

Here is flutter code

var file = await http.MultipartFile.fromPath("file", _file[0].path);
var file2 = await http.MultipartFile.fromPath("file2", _file[1].path);
var file3 = await http.MultipartFile.fromPath("file3", _file[2].path);
request.files.add(file);
request.files.add(file2);
request.files.add(file3);
http.StreamedResponse response = await request.send();`

here is php code

<?php
  $file = $_FILES['file']['name'];
  $file2 = $_FILES['file2']['name'];
  $file3 = $_FILES['file3']['name'];
  $imagePath = 'upload/'.$file;
  $imagePath2 = 'upload/'.$file2;
  $imagePath3 = 'upload/'.$file3;
  $tmp_name = $_FILES['file']['tmp_name'];  
  $tmp_name2 = $_FILES['file2']['tmp_name2'];
  $tmp_name3 = $_FILES['file3']['tmp_name3'];
      move_uploaded_file($tmp_name,$imagePath);
      move_uploaded_file($tmp_name2,$imagePath2);
      move_uploaded_file($tmp_name3,$imagePath3);
 ?>

I am trying to upload three files to server but only one file is uploaded

How to create a website Using HTML,JS AND PHP ALL IN SEPARATE FILES

I want my HTML Files to be .html and send the form data to Javascript which will proceed and send them to the php file which is separated as well. And I want to point out that the HTML FILE IS .HTML JS .JS AND PHP .PHP and they are not in 1 file !!

Clearing : The Problem Is that I didn’t Find a method to Send the Data from Js to Php !!

Liveness probe for long running PHP CLI job

we have a batch data processing script inside a container and want to check it is alive and actually working or whether it should be restarted.

It is PHP command line script and doesn’t expose any kind of server. Currently running in Docker soon in Kubernetes.

How can we monitor liveness of such script without introducing unnecessary features/libraries?

Laravel 9 Eloquent

Hello i’m trying to use eloquent in my code:

        $nr_riga = 0;
        
        foreach($data_detail as $key => $row_detail) {
            
            $nr_riga = $key + 1;

            $new_orders_details->nr_riga = $nr_riga;
            $new_orders_details->codice_articolo = $row_detail['codice_articolo'];
            $new_orders_details->quantita = $row_detail['quantita'];
            $new_orders_details->prezzo = $row_detail['prezzo'];
            $new_orders_details->order_id = $new_orders_grid->id;
            $new_orders_details->save();
            
            // DB::table('orders_detail')->insert([

            //     'order_id' => $new_orders_details->order_id,

            //     'nr_riga' => $nr_riga,

            //     'codice_articolo' => $new_orders_details->codice_articolo,
                
            //     'quantita' => $new_orders_details->quantita,
                
            //     'prezzo' => $new_orders_details->prezzo,
                
                
            //     ]);
            
        }

This loop works both ways but not equally.. when i use $new_orders_details->save(); it inserts to the db a single row,seems to not looping.

DB::table(‘orders_detail’)->insert does the job as i want.

How to convert it to eloquent for have same result?

This is the db screen:
enter image description here

can not get x_username header in nginx/1.20.1

i sent x_username header with curl to my site and i see this header in tcpdump but nginx do not pass it to my php-fpm

        location ~ .php$ {
            try_files $uri =404;
            fastcgi_pass   127.0.0.1:9070;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }

curl command

curl --location -k  --request POST 'https://xxxxx.com/test.php' 
--header 'Accept: application/json' 
--header 'Content-Type: application/x-www-form-urlencoded' 
--header 'x_username: xxxx' 
--data-urlencode 'login_username=xxxxxx'

nginx version is nginx/1.20.1

php version is 70

when i removed _ from header name and it worked but x_username not work ( xusername work )

I have a table and i want total row of bitwen 2 dates and like colu ‘e ‘and exclude col2 ‘ob_done’ and ‘rebook’

I have a table and i want total row of bitwen
2 dates and like colu ‘e ‘and exclude col2 ‘ob_done’ and ‘rebook’

date col1 col2
2-7-2022 e162ez job_done
2-7-2022 e16 2ex job_done
2-7-2022 e16 2xx null
2-8-2022 rm1 25z rebok
2-8-2022 e17 2ex rebok
2-8-2022 rm1 25z null
2-8-2022 rm1 25z rebok

i try this query but its not working.please help me

SELECT * 
FROM trans   
WHERE collect_date BETWEEN '".$collect_date1."' AND '".$collect_date2."'
  AND col1 LIKE '". 'e' ."%' 
  AND col2 NOT LIKE '". 'job_done'  ."%' 
  AND cal2 NOT LIKE '". 'rebook'  ."%'");

Selected attribute isn’t working in InertiaJS

I looked everywhere to solve this one but I couldn’t find any information about it. I have a normal select HTML tags with dynamic options and a form. All I need is to show the latest created category as the selected option by default so I’m passing the options from laravel with orderByDesc and I can see that when I click on the dropdown it shows the latest on top but it never show any value by default which means selected attribute isn’t working.

web.php

'categories' => auth()->user() ?
            category::where('user_id', auth()->user()->id)->orderByDesc('created_at')->get()
            : []

frontend

<select
                        name="category_id"
                        id="category_id"
                        class="min-w-max text-sm text-gray-900 bg-transparent border-2 rounded-xl"
                        v-model="productForm.category_id"
                    >
                        <option
                            v-for="category in categories"
                            :key="category.id"
                            :value="category.id"
                            selected
                        >
                            {{ category.name }}
                        </option>
                    </select>

the form

const productForm = useForm("createProduct", {
    category_id: null,
    categName: null,
    title: null,
    price: null,
    type: null,
    currency: null,
    desc: null,
    qty: null,
    thumbnail: null,
});

If there is a better approach to select menus with InertiaJS I would really appreciate your help

Struggling with a button for pay on the table

I am new to this. I have this function here thaat returns my table and inside a table there’s a button now I want to be clicked to update a table but somehow it’s updating everything when I click on the Pay button in one of the row in my table. I am not sure where I am going wrong with it. Please help

function lue_custom_view() {
 global $wpdb,$table_prefix;


 $output .= '<table>
  <tr style="color: #fff; background: #08a873; font-weight: bold;">
    <th> &nbsp; Account ID</th>
   
    <th>Deposited Amount</th>
    <th>Deposit Date</th>
    <th>Period</th>
    <th>Counter [Days]</th>
    <th>Amount Growth</th>
    <th colspan="2">Total  Return</th>
   
    

  </tr>';
  $approve = "Approved";
 $tbl_name  = $wpdb->prefix."member_deposit";

$results = $wpdb->get_results("select * from  $tbl_name where conf_deposit = 'Yes' AND approve = 'unapprove'");

 $current_date = date('Y-m-d H:i:s');
 
 foreach( $results as $user_data) {
        
       
        $startTimeStamp = strtotime($user_data->deposit_date);
        $endTimeStamp = strtotime($current_date);
        
        $timeDiff = abs($endTimeStamp - $startTimeStamp);
        
        $numberDays = $timeDiff/86400;  // 86400 seconds in one day
        
        // and you might want to convert to integer
        $numberDays = intval($numberDays);
        
        $realP = $user_data->period;
        $myPeriod = 0;
                    
                    if($realP == 2){
                        
                        $myPeriod = 60;
                    }
                     if($realP == 3){
                        
                        $myPeriod = 90;
                    }
                     if($realP == 4){
                        
                        $myPeriod = 120;
                    }
                     if($realP == 5){
                        
                        $myPeriod = 150;
                    }
                     if($realP == 6){
                        
                        $myPeriod = 180;
                    }
                      if($realP == 7){
                        
                        $myPeriod = 210;
                    }
                    
    
       $roi = $myPeriod * 0.02 * $user_data->amount +  $user_data->amount;  
       $amount_growth = $myPeriod * 0.02 * $user_data->amount;
       
       $name = $wpdb->get_var('SELECT user_nicename FROM '.$table_prefix.'users WHERE ID = '.$user_data->ID);

 if($realP==2 && $numberDays >= 60){
    
     $output .= "<tr style='background-color: red; color: #fff'>
    <td> $user_data->ID</td>
    
    <td> R$user_data->amount</td>
    <td> $user_data->deposit_date</td>
    <td> $realP</td>
    <td> $numberDays</td>
    <td> R$amount_growth</td>
    <td> R$roi</td>
    <td> <form method='post'> <input type='submit' name='submit' value='Pay' /> </form> </td>
    
  </tr>";
   
     //Add Withdrawal
     if($_POST['submit']) {
      $todate = date('Y-m-d H:i:s');   
         
     $success = $wpdb->insert("wp_member_history", array(
       
       "ID" => $user_data->ID,
       "amount" => $user_data->amount,
       "wit_date" => $todate
    ));
    
    //Update Member Status
    $status = "Approved";
    $where = array('ID' => $user_data->ID);
        $subs = array('approve' => $status);
        $table_name  = $wpdb->prefix."member_deposit";
        
        $wpdb->update($table_name, $subs, $where);
        
        
     if($success) {
       header('Location: http://empireinvest.co.za/RegSuccess');
       exit;
          } else {
       echo 'not';
       }
       
         
     }
     
 } elseif($realP==3 && $numberDays >= 90){
        $output .= "<tr style='background-color: red; color: #fff'>
    <td> $user_data->ID</td>
    
    <td> R$user_data->amount</td>
    <td> $user_data->deposit_date</td>
    <td> $realP</td>
    <td> $numberDays</td>
    <td> R$amount_growth</td>
    <td> R$roi</td>
    <td> <form method='post'> <input type='submit' name='submit' value='Pay' /> </form> </td>
    
  </tr>";
   
     //Add Withdrawal
     if($_POST['submit']) {
      $todate = date('Y-m-d H:i:s');   
         
     $success = $wpdb->insert("wp_member_history", array(
       
       "ID" => $user_data->ID,
       "amount" => $user_data->amount,
       "wit_date" => $todate
    ));
    
    //Update Member Status
    $status = "Approved";
    $where = array('ID' => $user_data->ID);
        $subs = array('approve' => $status);
        $table_name  = $wpdb->prefix."member_deposit";
        
        $wpdb->update($table_name, $subs, $where);
        
        
     if($success) {
       header('Location: http://empireinvest.co.za/RegSuccess');
       exit;
          } else {
       echo 'not';
       }
       
         
     }
 }
 elseif($realP==4 && $numberDays >= 120){
        $output .= "<tr style='background-color: red; color: #fff'>
    <td> $user_data->ID</td>
    
    <td> R$user_data->amount</td>
    <td> $user_data->deposit_date</td>
    <td> $realP</td>
    <td> $numberDays</td>
    <td> R$amount_growth</td>
    <td> R$roi</td>
    <td> <form method='post'> <input type='submit' name='submit' value='Pay' /> </form> </td>
    
  </tr>";
   
     //Add Withdrawal
     if($_POST['submit']) {
      $todate = date('Y-m-d H:i:s');   
         
     $success = $wpdb->insert("wp_member_history", array(
       
       "ID" => $user_data->ID,
       "amount" => $user_data->amount,
       "wit_date" => $todate
    ));
    
    //Update Member Status
    $status = "Approved";
    $where = array('ID' => $user_data->ID);
        $subs = array('approve' => $status);
        $table_name  = $wpdb->prefix."member_deposit";
        
        $wpdb->update($table_name, $subs, $where);
        
        
     if($success) {
       header('Location: http://empireinvest.co.za/RegSuccess');
       exit;
          } else {
       echo 'not';
       }
       
         
     }
 }
 elseif($realP==5 && $numberDays >= 150){
        $output .= "<tr style='background-color: red; color: #fff'>
    <td> $user_data->ID</td>
    
    <td> R$user_data->amount</td>
    <td> $user_data->deposit_date</td>
    <td> $realP</td>
    <td> $numberDays</td>
    <td> R$amount_growth</td>
    <td> R$roi</td>
    <td> <form method='post'> <input type='submit' name='submit' value='Pay' /> </form> </td>
    
  </tr>";
   
     //Add Withdrawal
     if($_POST['submit']) {
      $todate = date('Y-m-d H:i:s');   
         
     $success = $wpdb->insert("wp_member_history", array(
       
       "ID" => $user_data->ID,
       "amount" => $user_data->amount,
       "wit_date" => $todate
    ));
    
    //Update Member Status
    $status = "Approved";
    $where = array('ID' => $user_data->ID);
        $subs = array('approve' => $status);
        $table_name  = $wpdb->prefix."member_deposit";
        
        $wpdb->update($table_name, $subs, $where);
        
        
     if($success) {
       header('Location: http://empireinvest.co.za/RegSuccess');
       exit;
          } else {
       echo 'not';
       }
       
         
     }
 }
 elseif($realP==6 && $numberDays >= 180){
        $output .= "<tr style='background-color: red; color: #fff'>
    <td> $user_data->ID</td>
    
    <td> R$user_data->amount</td>
    <td> $user_data->deposit_date</td>
    <td> $realP</td>
    <td> $numberDays</td>
    <td> R$amount_growth</td>
    <td> R$roi</td>
    <td> <form method='post'> <input type='submit' name='submit' value='Pay' /> </form> </td>
    
  </tr>";
   
     //Add Withdrawal
     if($_POST['submit']) {
      $todate = date('Y-m-d H:i:s');   
         
     $success = $wpdb->insert("wp_member_history", array(
       
       "ID" => $user_data->ID,
       "amount" => $user_data->amount,
       "wit_date" => $todate
    ));
    
    //Update Member Status
    $status = "Approved";
    $where = array('ID' => $user_data->ID);
        $subs = array('approve' => $status);
        $table_name  = $wpdb->prefix."member_deposit";
        
        $wpdb->update($table_name, $subs, $where);
        
        
     if($success) {
       header('Location: http://empireinvest.co.za/RegSuccess');
       exit;
          } else {
       echo 'not';
       }
       
         
     }
 }
 elseif($realP==7 && $numberDays >= 210){
        $output .= "<tr style='background-color: red; color: #fff'>
    <td> $user_data->ID</td>
    
    <td> R$user_data->amount</td>
    <td> $user_data->deposit_date</td>
    <td> $realP</td>
    <td> $numberDays</td>
    <td> R$amount_growth</td>
    <td> R$roi</td>
    <td> <form method='post'> <input type='submit' name='submit' value='Pay' /> </form> </td>
    
  </tr>";
   
     //Add Withdrawal
     if($_POST['submit']) {
      $todate = date('Y-m-d H:i:s');   
         
     $success = $wpdb->insert("wp_member_history", array(
       
       "ID" => $user_data->ID,
       "amount" => $user_data->amount,
       "wit_date" => $todate
    ));
    
    //Update Member Status
    $status = "Approved";
    $where = array('ID' => $user_data->ID);
        $subs = array('approve' => $status);
        $table_name  = $wpdb->prefix."member_deposit";
        
        $wpdb->update($table_name, $subs, $where);
        
        
     if($success) {
       echo "<script> alert('Member order has been approved'); </script>";
           
           header("Refresh:0");
           exit;
          } else {
       echo 'not';
       }
       
         
     }
 }
 else  {
 $output .= "<tr>
   <td> $user_data->ID</td>
    <td> R$user_data->amount</td>
    <td> $user_data->deposit_date</td>
    <td> $realP</td>
    <td> $numberDays</td>
    <td> R$amount_growth</td>
    <td> R$roi</td>
    
  </tr>";
 }
 }
 $output .= '</table>';

 return $output;
}
add_shortcode('views', 'lue_custom_view');

//example usae with php
echo do_shortcode( $content, '[lue_custom_view]' 

);

how to loop in append table by ajax

i have this code and working but the result in append table return duplicated rows
how i can return records without duplicate rows ?
[enter image description here][1]
[1]: https://i.stack.imgur.com/nujQ8.png

`
$.ajax({
url: “”,
type: “POST”,
dataType: “json”,
data: {stdID: stID},

            success: function(response){ 
           var len = response.length;
            
       // Read values
       $("#tabledata").html("");//افراغ الجدول
                    var _qnumber = response[0].qnumber;
                    var _total = response[0].total;
                    var _isprint = response[0].is_print;
                    if(_isprint ==1){_isprint='نعم'}else{_isprint='لا'};
                    var _istest = response[0].istest;
                    if(_istest ==1){_istest='نعم'}else{_istest='لا'};
                    var _voice = response[0].voice;
                    for (var option = 0; option <response.length; option++) {
                      $('#tabledata').append(
                        '<tr><td>'+ _qnumber + '</td><td>' + _total + '</td><td>' 
                        + _istest 
                        + '</td><td>'
                        + _isprint
                        + '</td><td>'
                        + _voice
                        + '</td></tr>')
       }
                
    }// response success 

`

Woocommerce – Add Shipping form under the Edit Account page

Im trying to add shipping form under the My Account – Edit Account page.

Under the form-edit.account.php file, at the very bottom I added

<?php get_template_part( 'woocommerce/myaccount/form-edit', 'address' ); ?>

and I got Billing and shipping information at the bottom of the Edit Account Page. In order to see shipping form I have to click on “Add” link, below “Shipping Address” caption.
But I want shipping form to be directly displayed under the Edit Account page so i can fill it up and save.

How to do that ?

How do i get docker/ nginx to mount on my index file

I am trying to containerise and run my website on a PHP webserver with an nginx conf file (site.conf) and docker-compose.yml file. When I go to localhost:8080 I get the default nginx welcome page instead of the my index.html file. and When I go to php-docker.local:8080 I get a “this site cannot be reached message”.

Code Section

HTML

<!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.0">

    <!-- Font Awesome icons (free version)-->
    <script src="https://use.fontawesome.com/releases/v6.1.0/js/all.js" crossorigin="anonymous"></script>
    
    <title>Registration</title>
    <link rel="stylesheet" href="css/styles.css">
    <link rel="icon" type="image/x-icon" href="assets/favicon.ico" />


    

    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
</head>
<body class="container">
    <div class="container">
      <h1>Registration</h1>
      <section>
        <form id="regForm" action="form.php" method="post">
          <div class="form-group">
            <label for="nameInput">Name</label>
            <input type="text" class="form-control" id="nameInput" name="studentName" aria-describedby="emailHelp" placeholder="Enter your full name">
          </div>
          <div class="form-group">
            <label for="loginInput">Login</label>
            <input type="text" class="form-control" id="loginInput" name="studentId"  placeholder="Enter your login">
          </div>

          
          <button type="submit" name="submit" value="submit" class="btn btn-primary" id="submitForm">Submit</button>
        </form>
      </section>
    </div>
    
    

    
    <script src="js/regForm.js"></script>
    <!-- Datatable -->
    <!-- <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.js"></script> -->
    <!-- <script src="https://cdn.startbootstrap.com/sb-forms-latest.js"></script> -->
    
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>

PHP

<?php


echo "Submitted";

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

$data = '';
$filename = "data.json";
//if file exists
if(is_file($filename)) {
    $data = file_get_contents($filename);
}

$json_arr = json_decode($data,true);

$json_arr[] = array(
    'studentId' => $_POST['studentId'],
    'studentName' => $_POST['studentName'],
    
);

file_put_contents($filename, json_encode($json_arr));

}

?>

docker-compose.yml

version: '3'

services:
  web:
    image: nginx:latest
    volumes:
      - ./src:/src
      - ./site.conf:/etc/nginx/conf.d/site.conf
    ports:
      - "8080:80"
    links:
      - php
  php:
    image: php:7-fpm

site.conf (nginx conf file)

server {
    index index.html;
    server_name php-docker.local;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /src;
}

file/folder structure

-form
  -src
    -index.html
    -form.php
  -docker-compose.yml
  -site.conf

*** localhost Output ***
localhost:8080

localhost:8080

php-docker.local:8080

php-docker.local:8080