PHP Undefined array key warning

I am creating an associative array from XML feed using foreach as you see here:

function load_xml() {
        global $db;

        if(!$xml=simplexml_load_file($this->path)){
            trigger_error('Error reading XML file',E_USER_ERROR);
            }
        foreach ($xml as $item) {
            $xml_items[] = $item_url;
            $data[] = ['item_id' => null,
                       'title' => $item->PRODUCT->__toString(),
                       'title_draft' => null,
                       'description' => $item->DESCRIPTION_SHORT->__toString(),
                       'description_draft' => null,
                       'text' => $item->DESCRIPTION->__toString(),
                       'text_draft' => null,
                       'item_url' => $item->URL->__toString(),
                       'merchant' => $item->MANUFACTURER->__toString(),
                       'price' => $item->PRICE_VAT->__toString(),
                       'price_initial' => $item->PRICE_VAT_SALE->__toString(),
                       'language_id' => 1,
                       'subcategory_id' => 0,
                       'head' => null,
                       'ean' => null,
                       'code' => null,
                       'category_id' => 0,
                       'subcategory_id' => 0,
                       'action' => 0,
                       'rank' => 0,
                       'keywords' => "",
                       'published' => 0];

        }
        return $data;
    }

But when I try to use the values in this load_existing_items function I get warning undefined array key:

function load_existing_items(){
        global $db;

        $data = $this->load_xml();

        foreach($data as $key => $value){
            $item_url = $data['item_url'];
            $merchant = $data['merchant'];
            $result = $db->query("SELECT url FROM item WHERE  url = '$item_url' AND manufacturer = '$merchant'");

            while(($row = mysqli_fetch_assoc($result))) {
            $this->$db_items[] = $row['url'];
        }
        }
    }   

This is most likely some kind of a really primitive mistake that I made last night while I was desperately finish the code. Thank you for any advice/help.

PHP list() expects numerical indexes in v7.4.6 [duplicate]

In the PHP manual, I read:

Before PHP 7.1.0, list() only worked on numerical arrays and assumes the numerical indices start at 0.

My code:

echo 'Current PHP version: ' . phpversion() . "n" ;
print_r( $Item ) ;
list( $Cost, $Quantity, $TotalCost ) = $Item ;

Output:

Current PHP version: 7.4.6
Array
(
    [cost] => 45800
    [quantity] => 500
    [total_cost] => 22900000
)
PHP Notice:  Undefined offset: 0 in D:OneDriveworkTornpm.php on line 27

Notice: Undefined offset: 0 in D:OneDriveworkTornpm.php on line 27
PHP Notice:  Undefined offset: 1 in D:OneDriveworkTornpm.php on line 27

Notice: Undefined offset: 1 in D:OneDriveworkTornpm.php on line 27
PHP Notice:  Undefined offset: 2 in D:OneDriveworkTornpm.php on line 27

Notice: Undefined offset: 2 in D:OneDriveworkTornpm.php on line 27

It seems to me that this version of PHP expects that the indexes are numerical, even if v7.4.6 should be greater than v7.1.0.
Am I missing something?

Image Upload in Livewire

When i login bay Sentinel package Then Livewire File Upload Faild. But Without Sentinel Login Livewire File Upload Working. How To File File/image upload in Livewire when login with sentinel ?

Calculating Average (Mean) in PHP

I’m a bit of a beginner with PHP and am implementing a review aggregator system for a few products.

I have created the input fields and am outputting the results from these fields using this code:

{ echo '<div class="review1">Review 1: '; the_field('review1'); '</div>';}
{ echo '<div class="review2">Review 2: '; the_field('review2'); '</div>';}
{ echo '<div class="review3">Review 3: '; the_field('review3'); '</div>';}
{ echo '<div class="review4">Review 4: '; the_field('review4'); '</div>';}
{ echo '<div class="review5">Review 5: '; the_field('review5'); '</div>';}

I want to use PHP to calculate the average (mean) however the number I am using to calculate this is set to 5 as that is the total number of number fields I have. Here is the code I am using

{ echo (get_field('review1')+get_field('review2')+get_field('review3')+get_field('review4')+get_field('review5'))/5;}

The problem with this method is that sometimes the fields will not contain a value so the number to divide by would need to be 1, 2, 3 or 4 instead of 5 depending on the total number of review fields that have a value.

Essentially I need to replace “/5” with “/n” where “n” is the total number of fields with values.

Can anyone please assist?

Regards,
Peter

Don’t output indent before PHP open tag

I am trying to style my PHP script like a templating language, but the problem is, that PHP outputs the indentation before <?php tags like this:

<ul>
    <? foreach ($arr as $val) { ?>
        <li><?= $val ?></li>
    <? } ?>
</ul>

This works, but outputs

<ul>
            <li>a</li>
            <li>b</li>
    </ul>

and that is terrible.

Is there a way to not output the indentation before PHP tags?


Secondly, the <li> tag is indented twice, but I want to remove one indentation level.

Is that possible?

Enter multiple rows in an MySQL table by pressing the Submit button in a PHP Form

So to preface – I’m trying to implement a “Mark Attendance” feature on my website where I’m printing all the registered students in a table (that is wrapped in ) – each student has a “Present / Absent” radio button and once the admin has selected his preferred option, he presses “Submit” and the form should mark all students Present OR Absent i.e insert multiple rows (equal to the number of total students in the table) with their Attendance Status i.e Absent or Present.

Following is the HTML part of the code (mixed with some PHP):

<form action="adminmarkattendance.php" method="post">
                                <div class="row">
                                    <div class="col">
                                        <div class="card bg-default shadow">
                                            <div class="card-header bg-transparent border-0">

                                                <div class="form-inline">
                                                    <div class="col-lg-6">
                                                        <h3 class="text-white mb-0">Registered Students</h3>
                                                    </div>
                                                    <div class="col-lg-6">
                                                        <div class="form-group">
                                                            <input style="width: 100%;" class="form-control" name="attendancedate" type="date" required>

                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="table-responsive" style="overflow-y: scroll; height: 600px;">
                                                <table class="table align-items-center table-dark table-flush">
                                                    <thead class="thead-dark">
                                                        <tr>

                                                            <th scope="col" class="sort" data-sort="name">Avatar</th>
                                                            <th scope="col" class="sort" data-sort="name">Student Name</th>
                                                            <th scope="col" class="sort" data-sort="status">Phone Number</th>
                                                            <th scope="col" class="sort" data-sort="status">Age</th>
                                                            <th scope="col" class="sort" data-sort="status">Gender</th>
                                                            <th scope="col" class="sort" data-sort="status">Address</th>
                                                            <th scope="col" class="sort" data-sort="status">Action</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody class="list">
                                                        <?php
                                                        foreach ($getRows as $row) {
                                                            $i = 0; ?>
                                                            <tr>
                                                                <td>
                                                                    <img src="<?php echo '../profileImages/' . $row['profile_image'] ?>" width="45" height="45" alt="">
                                                                    <input type="hidden" name="id" value="<?php echo $row['student_id']; ?>">
                                                                </td>
                                                                <th scope="row">
                                                                    <div class="media align-items-center">

                                                                        <div class="media-body">
                                                                            <span class="name mb-0 text-sm"><?php echo $row['fname'] . ' ' . $row['lname']; ?></span>
                                                                        </div>
                                                                    </div>
                                                                </th>

                                                                <td>
                                                                    <span class="badge badge-dot mr-4">
                                                                        <span class="status"><?php echo $row['phonenumber']; ?></span>
                                                                    </span>
                                                                </td>
                                                                <td>
                                                                    <span class="badge badge-dot mr-4">
                                                                        <span class="status"><?php echo $row['age']; ?></span>
                                                                    </span>
                                                                </td>
                                                                <td>
                                                                    <span class="badge badge-dot mr-4">
                                                                        <span class="status"><?php echo $row['gender']; ?></span>
                                                                    </span>
                                                                </td>
                                                                <td>
                                                                    <span class="badge badge-dot mr-4">
                                                                        <span class="status"><?php echo $row['address']; ?></span>
                                                                    </span>
                                                                </td>
                                                                <td>
                                                                    <div class="btn-group btn-group-toggle" data-toggle="buttons">
                                                                        <label class="btn btn-secondary active">
                                                                            <input type="radio" name="options" value="present" id="option1" autocomplete="off" checked> Present
                                                                        </label>
                                                                        <label class="btn btn-secondary">
                                                                            <input type="radio" name="options" value="absent" id="option2" autocomplete="off"> Absent
                                                                        </label>
                                                                    </div>
                                                                </td>

                                                            </tr>
                                                        <?php } ?>
                                                    </tbody>
                                                </table>

                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="text-center">
                                    <button type="submit" name="submit" style="width: 100%;" class="btn btn-warning">Mark Attendance</button>
                                </div>
                            </form>

PHP:

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

    $student_id = $_POST["id"];
    $date = $_POST['attendancedate'];
    $date = date('Y-m-d', strtotime($date));
    $status = $_POST['options'];

    $queryInsert = $conn->prepare("INSERT
       into attendance
       (
       student_id,
       date,
       status
       )
       values 
       (
       $student_id,
       '$date',
       '$status'
       )
  ");
  $queryInsert->execute();
  

    echo "<script> location.replace('adminmarkattendance.php'); </script>";
}

As you can probably see in the code – I’m only trying to insert the student’s ID, date & his present/absent status.

Now, when I press submit, the information of only 1 student is inserted into the Attendance table. Usually, the last student. Which is not what I want – I want X number of rows inserted when I press submit, where X is equal to the number of students in the table.

How do I achieve this? Thank you for reading.

Laravel 8 Localisation Using mcamara package

I am trying to use multi language in my laravel 8 application frontend. I have used mcamara package, and set it up as per the guide on github.

I Have a form which accepts a input, which fetches the user. Based on the condition (if the user has taken survey, downloads a file. else shows the survey form and then redirects to download).

This is working absolutelyn fine in both languages. I am able to view the form in both languages, but once i enter the view page after id submission and i click on the language change button, i get this

SymfonyComponentHttpKernelExceptionMethodNotAllowedHttpException
The GET method is not supported for this route. Supported methods: POST.

The issue is only in the POST method. Rest works fine.
Can someone help me on how to fix this?

Thanks in advance.

My route file

Route::redirect('/', 'en');

Route::group(['prefix' => LaravelLocalization::setLocale()], function()
{

    Route::get('/', function () {
        return redirect()->route('certificate.download');
        // return view('welcome');
    });



    // Frontend
    Route::prefix('/registration')->group(function(){
        Route::get('/add', [RegController::class, 'RegEnqAppAdd'])-> name('reg.add');
        Route::get('signature_pad', [RegController::class, 'index']);
        Route::post('signature_pad', [RegController::class, 'store'])->name('signature_pad.store');
        Route::post('/store', [RegController::class, 'RegEnqAppAddStore'])-> name('reg.store');
        });

    // Frontend Downloads
    Route::prefix('/downloads')->group(function(){
        Route::get('/certificate', [DownloadController::class, 'DownloadCertificate'])-> name('certificate.download');
        Route::get('/addcertificate/{id}', [DownloadController::class, 'AddCertificate'])-> name('certificate.add');
        Route::get('/addcertificate/group/{id}', [DownloadController::class, 'AddCertificateGroup'])-> name('groupcertificate.add');
        Route::post('/storecertificate', [DownloadController::class, 'StoreCertificate'])-> name('certificate.store');
        Route::post('/viewcertificate', [DownloadController::class, 'ViewCertificate'])-> name('certificate.view');
        Route::get('/viewcertificates/{id}', [DownloadController::class, 'ViewCertificateRedirect'])-> name('certificateredirect.view');
        Route::get('/deletecertificate/{id}/{bid}', [DownloadController::class, 'DeleteCertificateBatch'])-> name('certificate.delete');
        Route::get('/deletegroupcertificate/{id}/{gid}', [DownloadController::class, 'DeleteCertificateGroup'])-> name('groupcertificate.delete');
        });

    // Frontend Surveys
    Route::prefix('/surveys')->group(function(){
        Route::get('/post-training-questionaire/{id}',   [SurveyController::class, 'PostTrainingQuestionaire'])-> name('surveys.posttraining');
        Route::post('/post-training-questionaire/store', [SurveyController::class, 'PostTrainingQuestionaireStore'])-> name('surveys.posttrainingstore');
        });
});
// Frontend Group
// Frontend Group

My Initial View File (id input)

@extends ('frontendlayouts.frontend_master')
@section ('frontendbody')

<script src="https://code.jquery.com/jquery-3.6.0.min.js"integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="  crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>

{{-- <link href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"> --}}


    <div class="content-wrapper">
        <div class="container-full">

            <div class="row">
                <div class="col-md-12">

                    <div class="content-header">
                        <div class="d-flex align-items-center">
                            <div class="mr-auto">
                                <div>
                                    <img src="{{ asset('backend/images/amilogo.png') }}" width="150px" alt="">
                                </div>

                                <h3 class="page-title" style="border-right: none;">Downloads - Certificate Download</h3>
                                    <div class="align-items-center">
                                        <nav>
                                            <ol class="breadcrumb">
                                                <li class="breadcrumb-item"><a href="#"><i class="mdi mdi-home-outline"></i></a></li>
                                                <li class="breadcrumb-item active" aria-current="page">{{ __('Course Certificate') }}</li>
                                            </ol>
                                        </nav>
                                    </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>

            <section class="content">
                <div class="box">
                    <div class="box-header with-border">
                        <h4 class="box-title">{{ __('Enter Your CPR Number to Download Your Certificates') }}</h4>
                    </div>
                    <form class="form" method="post" action="{{ route('certificate.view') }}" enctype="multipart/form-data" id="posttrainingquestionaire">
                        @csrf
                        <div class="box-body">

                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label>{{ __('CPR Number') }}</label>
                                        <input type="text" name="cprnumber" id="cprnumber" class="form-control" maxlength="9" placeholder="CPR Number" required data-validation-required-message="This field is required">
                                    </div>
                                        @error('cprnumber')
                                        <span class="text-info">{{ $message }}</span>
                                        @enderror
                                </div>
                            </div>

                        </div>
                        <div class="box-footer">
                            <button onclick="$('#posttrainingquestionaire').submit()" class="btn btn-rounded btn-primary btn-outline">
                                <i class="ti-save-alt"></i> {{ __('Submit & Download') }}
                            </button>
                        </div>
                    </form>
                </div>
            </section>

        </div>
    </div>

@endsection

My view_certificate view

@extends ('frontendlayouts.frontend_master')
@section ('frontendbody')

<script src="https://code.jquery.com/jquery-3.6.0.min.js"integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="  crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>


    <div class="content-wrapper">
        <div class="container-full">

            <div class="content-header">
                <div class="d-flex align-items-center">
                    <div class="mr-auto">
                        <div>
                            <img src="{{ asset('backend/images/amilogo.png') }}" width="150px" alt="">
                        </div>

                        <h3 class="page-title" style="border-right: none;">Downloads - Certificate Download</h3>
                            <div class="align-items-center">
                                <nav>
                                    <ol class="breadcrumb">
                                        <li class="breadcrumb-item"><a href="#"><i class="mdi mdi-home-outline"></i></a></li>
                                        <li class="breadcrumb-item active" aria-current="page">{{ __('Course Certificate') }}</li>
                                    </ol>
                                </nav>
                            </div>
                    </div>
                </div>
            </div>

            <section class="content">
                <div class="box">
                    <div class="box-header with-border">
                        {{-- <h4 class="box-title">Enter Your CPR Number to Download Your Certificates</h4> --}}
                        <h1>{{ __('Welcome to Almoalem Institute') }}</h1>

                    </div>
                    <form class="form" method="post" action="{{ route('certificate.view' ) }}" enctype="multipart/form-data" id="posttrainingquestionaire">
                        @csrf
                        <div class="box-body">

                            <div class="row">
                                <div class="col-md-12">

                                    <div class="timeline-event">
                                        <div class="timeline-body">

                                            <div class="media-body">
                                                <div class="timeline-title"><strong>{{ __('CPR Number') }}:</strong></span> <span class="timeline-body">{{ $learnerData->cprnumber }}</span>
                                                    <br>
                                                <span class="timeline-title"><strong>{{ __('Full Name') }}:</strong></span> <span class="timeline-body">{{ $learnerData->fullname }}</span></div>
                                                <br>
                                                <br>

                                            </div>
                                        </div>
                                    </div>

                                    <div class="col-12">
                                        <div class="box">
                                            <div class="box-body no-padding">
                                                <div class="table-responsive">
                                                    <table class="table table-hover">
                                                        <tr>
                                                            <th>Sl. No</th>
                                                            <th>Course</th>
                                                            <th>Download Certificate</th>
                                                        </tr>
                                                        <?php $app =array(); ?>
                                                        @foreach($downloadData as $key => $dd)
                                                        <tr>
                                                            <td>{{ $key+1 }}</td>
                                                            <td>{{ $dd->applicationmanagement->courseapplied }}</td>
                                                            <td>
                                                                @if($dd->surveytaken!=NULL || in_array($dd->courseapplication_id, $app))
                                                                <?php $app[$key]=$dd->courseapplication_id;?>
                                                                <p class="text-black">
                                                                    <a  href="{{asset('certificate/'.$dd->certificate) }}" class="btn btn-primary md-5" target="_blank">{{ __('Download Certificate') }}</a>
                                                                </p>
                                                                @else
                                                                <a href="{{route('surveys.posttraining',$dd->id)}}" class="btn btn-dark md-5"> {{ __('Complete Training Feedback to Download Certificate') }}</a>

                                                                @endif
                                                            </td>
                                                        </tr>
                                                        @endforeach
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>


                                </div>
                            </div>

                        </div>
                    </form>
                </div>
            </section>

        </div>
    </div>

@endsection

laravel RSA decryption very slow

We are storing some consumer data in database. The sensitive data is stored in encryption format and we are encrypting the data using RSA encryption. We are using phpseclib for encryption in the laravel. We are using setters to encrypt the data at the time of storing to database.

    $rsa = new RSA();
    $publicfilecontent = Storage::disk('local')->get('publickey.txt');
    $rsa->loadKey($publicfilecontent); 
    $this->attributes['address'] = $rsa->encrypt($address);

This works fine and the data is stored in blob type in the database. The issue is that when we are retrieving the data from the database, the data for many consumers is returned at the same time. We are decrypting the addresses of these employees. Since MySQL does not offer decryption, we have to decrypt the address at the laraval level and it has to be done for each employee. See the example below.

$serviceproviders = Providers::where('city_id',$request->city_id)->get();

foreach ($serviceproviders as $key => $serviceprovider) {
  $rsa = new RSA();
  $privatefilecontent = Storage::disk('local')->get('privatekey.txt');
  $rsa->loadKey($privatefilecontent); 
  $address_decrypted= $rsa->decrypt($serviceprovider->address);
  $serprov_array[$key] = $serviceprovider;
  $serprov_array[$key]->distance_decrypted= $address_decrypted;
}

The above code works fine but the problem is that it is too slow. Only for 20 records, it took 5 sec to return the data in the mobile app while without the decryption, the data returns in 500 ms. We have to load hundreds of service providers so this performance is not at acceptable level at the moment.

Can someone please guide how to improve the performance of the decryption process?

How I can get total sum of daily values of a column in Laravel?

There is an orders table with a total column that has more than 1000 records. How I can get the daily sum of total for each day. I mean for Monday, Thursday, Wednesday, …. there are many and different rows, and I want to show the sum of total of each day separately? in UI as:

saturday: 111211,
sunday: 211444,
Monday: 120012000,
Thursday: 1225121,

How to save data on database from a dynamic table

How to save data on database from a dynamic table. I am able to display the invoices on the table, I would like to save individual rows only but instead, the table saves only the first reference(invoice) and the last amount

        <thead>
            <tr>
                <th class="text-md-left"><?php echo lang("nьз╕"); ?></th>
                <th class="text-md-left"><?php echo lang("date"); ?></th>
                <th class="text-md-left"><?php echo lang("invoice"); ?></th>
                <th class="text-md-right"><?php echo lang("amount"); ?></th>
                <th class="text-md-right"><?php echo lang("amount_due"); ?></th>
                <th class="text-md-right"><?php echo lang("payments_create"); ?></th>
            </tr>
        </thead>
        <tbody>
            <?php
            $amount = 0; $k = 1; $sp = strlen(count($invoices)."");
            foreach ($invoices as $row) {
                if(is_object($row)){$row = objectToArray($row);} ?>
                <tr>
                    
                    <td class="text-md-left"><?php echo str_pad($k, $sp, "0", STR_PAD_LEFT) ?></td>
                    <td class="text-md-left"><?php echo date_MYSQL_PHP($row["date"]) ?><small><small><br>Date Due <?php echo $row['date']; ?></small></small></td>
                    <td class="text-md-left"><?php echo form_input ($invoice_input); echo $row["reference"],
       form_hidden('receipt[invoice_id]', set_value('receipt[invoice_id]', $invoice_id)),
       form_hidden('payment[invoice_id]', set_value('payment[invoice_id]', $invoice_id));
      ?></td>
                    <td class="text-md-right"><?php echo formatMoney($row["total"], $currency); ?></td>
                    <td class="text-md-right"><?php echo formatMoney($row["total_due"], $currency); ?></td>
                    <td class="text-md-right"> 
        <input type="number" step="any" min="0" value="<?php foreach($row['payment'] as $payment)
    echo set_value("payment[amount]<br>", $invoice->total_due);  echo str_pad($k, "total_due") ?>" name="payment[amount]" class="form-control" />
     
     </td>
        
      
    </div></tr>
            <?php
                $k++;
                $amount += $row["amount"];
            } // end foreach
            ?> ```

headers already sent in php

The thing is on my local server its working just fine. Its only when it is uploaded
that it becomes an issue.This is the error i am getting&*/
Warning: Cannot modify header information – headers already sent by (output started
at /home/primepai/public_html/admin/userValidate.php:6) in
/home/primepai/public_html/admin/userValidate.php on line 38

<?php ob_start();?>
<?php session_start();?>
<?php 
//include config.php to connect to the database
include("../config.php");?>
<?php
if(isset($_POST['login'])){
$username= $_POST['username'];
$password= $_POST['password'];

$username = mysqli_real_escape_string($mysqli, $username);
$password = mysqli_real_escape_string($mysqli, $password); 
    
$query = "SELECT * FROM users WHERE username = '$username'";
$select_query = mysqli_query($mysqli, $query);

if(!$select_query){
    die("QUERY FAILED". mysqli_error($mysqli));
}
    
while($row = mysqli_fetch_array($select_query)){
$db_fullname = $row['full_name'];
$db_username = $row['username']; 
$db_password = $row['password'];
$db_userid = $row['user_id']; 
$db_userimage = $row['picture'];
}    
if ($username === $db_username && $password === $db_password){
$_SESSION['username'] = $db_username;
$_SESSION['full_name'] = $db_fullname;
$_SESSION['password'] = $db_password;
$_SESSION['user_id'] = $db_userid;
$_SESSION['picture'] = $db_userimage;
header("Location: dashboard.php");
die();
exit();
} else {
header("Location: index.php");
}  
}?>

HTML / Javascript einblenden der Virtuellen Touch Tastatur von Windows [closed]

Ich habe folgendes Problem.
Ich habe einen Touch Monitor an dem keine Tastatur angeschlossen ist.
Auf dem Monitor wird eine E-Mail Registrierung per HTML Seite angezeigt.

Mein Problem, die Windows Touch Tastatur wird nur automatisch eingeblendet wenn ich auf
ein Passwort Feld (und da nur beim Border) klicke. Bei E-Mail oder normalen Text Feldern wird die Tastatur nicht eingeblendet.

Hat hier wer eine Idee wie man das mit Javacript oder sonstiges erzwingen kann?

Set Focus auf das Password Feld funktioniert leider nicht.

LG
Martin

How to get data from one server and store in another server in PHP

I need to get mysql data from one server(host1) and store in to another server(host2).

Here is my try.

<?php
$servername = "host1";
$username = "root";
$password = "";
$dbname = "userdetails";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
  die("Connection failed: " . mysqli_connect_error());
}

//$sql = "SELECT ts, a, logic,status,rel,MAX(ts) OVER (PARTITION BY a) AS LastUpdated FROM block_queue_alltime order by ts";
$sql = "SELECT a,logic from usertable";

$result = $conn->query($sql);

if ($result->num_rows > 0) {
  // output data of each row
  $a=array();
  $logic=array();
  while($row = $result->fetch_assoc()) {
    $a[]=$row["a"];
    $logic[]=$row["logic"];
  }
  
} else {
  echo "0 results";
}

$servername2 = "host2";
$username2 = "root";
$password2 = "";
$dbname2 = "userdetails2";

$conn2 = mysqli_connect($servername2, $username2, $password2, $dbname2);

 if (!$conn2) {
  die("Connection failed: " . mysqli_connect_error());
} 
 
$sql2 = "INSERT INTO testdata (number, logic) VALUES ('$a', '$logic')";
 
$result2 = mysqli_query($conn2, $sql2);

if ($result2 === TRUE) {
    echo "New record created successfully";
  } else {
    echo "Error: " . $sql . "<br>" . $conn->error;
  }


mysqli_close($conn);
?>

I can see when print_r($a) and print_r($logic) provides the required array of numbers what I need. But when it inserting to another the table. It shows only zeros in the databases and New record created successfully also prints. Can someone show me an efficient way to store all the data from one host to another?