How to hide the div until the page load then show after the page completely loaded?

I want to hide the div till page load the i want show that div after the page is completely loaded, for that in my phtml file i tried this.

<div id='pilot' style="display : none">
    <div class="trustpilot-widget" data-locale="en-US" data-template-id="5406e6b0d049e042d5f" data-      businessunit-id="54c2a000ff00057c" data-style-height="28px" data-style-width="100%" data-theme="light">
<a href="https://www.trustpilot.com/review/www.mani.com" target="_blank" rel="noopener">Trustpilot</a>
    </div>
</div>
<script>
$(document).ready(function() {
    $("#pilot").show();
});
</script>

But its not working, any help can be appreciated.

WordPress loop not respecting my arguments

I created a WordPress loop for with specific arguments but it is just ignoring them. For example I like to list only posts but there are also pages listed.

<h1 id="" class="offset"><?php _e('Aktuell','Main'); ?></h1>
<?php 
// Restore original Post Data
wp_reset_postdata();

// WP_Query arguments
$args = array (
    'post_type'             => 'post',
    'cat'                   => '50,47',
    'numberposts'            => '3',
    'posts_per_page'         => '3',
    'ignore_sticky_posts'    => true,
    'order'                  => 'ASC',
    'orderby'              => 'menu_order',
);

// The Query
$query = new WP_Query( $args );

// The Loop
if ( $query->have_posts() ) {
    while ( $query->have_posts() ) {
        $query->the_post(); 
 ?>

<article <?php post_class(); ?>>

</article>

    <?php }
} else {
    // no posts found
}


?>  
</div>

how can i store my array values into multiple rows into database

my table looks like,

id | heading | description
     
 1 | head1,head2   | des1,des2
    

and i want it to be like this,

 id | heading | description
    
 1 | head1   | des1
     
 2 | head2   | des2

Here I am added values into table with ‘add more’ feature in frontend UI. These vales are fetched using array. after applying ‘implode’ method i could store it into a table. But unfortunately that values are stored with comma separated manner in a same row . how can i store these comma separated array values into different row?

UI:

                 <p>Add technical details below</p>

          <label class="label"> <strong> Warishan Names <strong> </label>
<div class="table-responsive">
    <table id="form_tablee" class="table table-bordered">
        <tr>
            <!-- <th>S. No</th> -->
            <th>heading</th>
            <th>Description</th>
        </tr>
        <tr class='case'>
            <!-- <td><span id='snum'>1.</span></td> -->
            <td><input class="form-control" type='text' name='heading[]'/></td>
            <td><input class="form-control" type='text' name='description[]'/></td>
           <input type="hidden" class="prodid" name="id">
        </tr>
    </table>
    <button type="button" class='btn btn-success addmoree'>+ add new field</button> <br>
</div>

<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"> -->
  <script>
$(document).ready(function(){
    $(".addmoree").on('click', function () {
        var count = $('table tr').length;
        var data = "<tr class='case'>";
        data += "<td><input class='form-control' type='text' name='heading[]'/></td> <td><input class='form-control' type='text' name='description[]'/></td></tr>";
        $('#form_tablee').append(data);
        count++;
    });
});
</script>

function:

<?php


    $heading = $_POST['heading'];

    $description = $_POST['description'];
    $id = $_POST['id'];

    if (isset($_POST["heading"]) && is_array($_POST["heading"])){ 
            
            $heading       = $_POST['heading'];
            $heading_str   =implode(",",$heading);
    }

    if (isset($_POST["description"]) && is_array($_POST["description"])){ 
            
            $description       = $_POST['description'];
            $description_str   =implode(",",$description);
    }

    



     $status="1";

    $conn = $pdo->open();



        try{
            
            $stmt = $conn->prepare("INSERT INTO tech (heading ,description ,pro_id) VALUES (:heading , :description ,:pro_id)");
            $stmt->execute(['heading'=>$heading_str,'description'=>$description_str,'pro_id'=>$id]);
            $_SESSION['success'] = ' successfully';
            
    

        }
        catch(PDOException $e){
            $_SESSION['error'] = $e->getMessage();
        }
    


       $pdo->close();
        header('location: products.php');
         ?>

How to validate a custom object with attributes using Symfony validation?

I’m working on a Symfony 6 application on PHP 8.1.

I’m trying to validate a custom DTO which has the properties marked with Assert attributes.

Here’s my DTO class

use JMSSerializerAnnotation as JMS;
use SymfonyComponentValidatorConstraints as Assert;

class JWTData
{
    #[JMSType('string')]
    #[JMSSerializedName('UserName')]
    #[AssertNotBlank]
    #[AssertNotNull]
    private string $userName;
}

And that’s the code I’m using to validate the DTO

$dto = $this->serializer->deserialize(json_encode($userDataArray), JWTData::class, 'json');
$errors = $this->validator->validate($dto);

Even if I provide an empty array as data, the validator not fires any constraint. Digging in the validator component, I discovered that the metadata related to my DTO class not contains the constraints added with the Assert attribute.
This is the Symfony’s configuration about validation

framework:
    validation:
        enabled: true
        enable_annotations: true
        email_validation_mode: html5

I tried also to debug the validator with this command php bin/console debug:validator "AppDtoAuthenticationJWTData" and the result shows correctly the constraints on the property.

enter image description here

What I’m missing? How can I validate correctly my class?

How to put a download function in PHP?

Can you help me on how can I apply a download function. I am using HTML, PHP and MYSQL for the database. I have this feature in my page wherein I will upload a file from my computer and it will be stored into the database. Now, how can I download a file from database using my download button?enter image description hereThis is the look of my page:

I tried to look for codes and expected for it to work but it does not. Can you help me?

How to make React App and php Api on the same repository, as one project

i have a react application which consume php api service, the php api is hosted on wampserver port 80 and react app on port 3000, so like to make the application and API on the same repository
how can i do that and what is it the best structure of directories i can do

the Api is located on www folder of wampserver and i couldn’t hosted API next to react App because this one is outside wampserver

Clinic request backend by Laravel

I’m working on a pet shop eCommerce pet shop, I wanna send a request to the user when he reverses an appointment for his pet so when I click on the button of the book now It doesn’t work
Could you please tell me where the problem is?

I’m looking for helping me to solve this problem so the request will be sent to the user

Remove an Element from an array with SimpleXML Objects

I need to remove an item from an array if that has a product which has a product_type bundle. I was able to recreate my array without the excluded products but I can’t override the original array with it. I have tried also unset, but the $key value always just hodl the flag not the actual index to the element.

Can someone point me to the right direction?

My code:

add_filter('wc_szamlazz_xml','wc_szamlazz_xml_product_bundle_torlese',10,2);

/* 
https://www.php.net/manual/en/class.simplexmlelement.php#112420
*/
function wc_szamlazz_xml_product_bundle_torlese($xml,$order) {

    $elementsToKeep = array();

    error_log("xml->tetelek ARRAY:");
    error_log(print_r($xml->tetelek, true)); 

    foreach($xml->tetelek->tetel as $tetel) {
        
        //error_log("KEY: " . $key );

        if ($tetel->azonosito){
            $product_id = iconic_get_product_id_by_sku($tetel->azonosito);

            $product = wc_get_product( $product_id ); 
            $product_type = $product->get_type();


            /* error_log("Product_ID: " . $product_id);
            error_log("Product_type: " . $product_type);

            error_log("NEV:" . $tetel->megnevezes);
            error_log(print_r($tetel, true)); */

            if ($product_type != "bundle"){
                $elementsToKeep[] = $tetel;
            }
        } else {
            $elementsToKeep[] = $tetel;
        }
    }

    error_log("elementsToKeep ARRAY:");
    error_log(print_r($elementsToKeep, true)); 

    foreach($xml->tetelek->tetel as $tetel) {
        foreach ($elementsToKeep as $uj_elem){
            $tetel = $uj_elem;
        }
    }

    //$xml->tetelek->tetel = $elementsToKeep;

    error_log("xml->tetelek ARRAY:");
    error_log(print_r($xml->tetelek, true)); 

    return $xml;
}

Original array with all the values:

SimpleXMLElement Object
(
    [tetel] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [megnevezes] => Villanypásztor szett kutyáknak, macskáknak 30m hosszú kerítésekhez gyűrűszigetelőkkel teszt
                    [azonosito] => vpszettkutyszig-30-bundle
                    [mennyiseg] => 1
                    [mennyisegiEgyseg] => SimpleXMLElement Object
                        (
                        )

                    [nettoEgysegar] => 0
                    [afakulcs] => 0
                    [nettoErtek] => 0
                    [afaErtek] => 0
                    [bruttoErtek] => 0
                    [megjegyzes] => SimpleXMLElement Object
                        (
                        )

                )

            [1] => SimpleXMLElement Object
                (
                    [megnevezes] => Fencee Mini M03 Villanypásztor Készülék 0,3 J
                    [azonosito] => fenceeminiM03
                    [mennyiseg] => 1
                    [mennyisegiEgyseg] => SimpleXMLElement Object
                        (
                        )

                    [nettoEgysegar] => 22826.77
                    [afakulcs] => 27
                    [nettoErtek] => 22826.77
                    [afaErtek] => 6163
                    [bruttoErtek] => 28989.77
                    [megjegyzes] => SimpleXMLElement Object
                        (
                        )

                )

            [2] => SimpleXMLElement Object
                (
                    [megnevezes] => Farmline Villanypásztor Gyűrűszigetelő, 1 db,
                    [azonosito] => farmlinegyuruszig
                    [mennyiseg] => 25
                    [mennyisegiEgyseg] => SimpleXMLElement Object
                        (
                        )

                    [nettoEgysegar] => 51.1812
                    [afakulcs] => 27
                    [nettoErtek] => 1279.53
                    [afaErtek] => 345
                    [bruttoErtek] => 1624.53
                    [megjegyzes] => SimpleXMLElement Object
                        (
                        )

                )

            [3] => SimpleXMLElement Object
                (
                    [megnevezes] => Villanypásztor Földelő rúd profil, hossza 100 cm, horganyzott
                    [azonosito] => foldrud100
                    [mennyiseg] => 1
                    [mennyisegiEgyseg] => SimpleXMLElement Object
                        (
                        )

                    [nettoEgysegar] => 3141.73
                    [afakulcs] => 27
                    [nettoErtek] => 3141.73
                    [afaErtek] => 848
                    [bruttoErtek] => 3989.73
                    [megjegyzes] => SimpleXMLElement Object
                        (
                        )

                )

            [4] => SimpleXMLElement Object
                (
                    [megnevezes] => Fence Guard ECONOMY MINI Villanypásztor Vezeték  100 m, 2mm, 3 vezetőszál - 40Kg - 14,4 Ω/m
                    [azonosito] => economymini100m
                    [mennyiseg] => 1
                    [mennyisegiEgyseg] => SimpleXMLElement Object
                        (
                        )

                    [nettoEgysegar] => 1488.19
                    [afakulcs] => 27
                    [nettoErtek] => 1488.19
                    [afaErtek] => 402
                    [bruttoErtek] => 1890.19
                    [megjegyzes] => SimpleXMLElement Object
                        (
                        )

                )

            [5] => SimpleXMLElement Object
                (
                    [megnevezes] => MPL Házhozszállítás
                    [mennyiseg] => 1
                    [mennyisegiEgyseg] => SimpleXMLElement Object
                        (
                        )

                    [nettoEgysegar] => 394
                    [afakulcs] => 27
                    [nettoErtek] => 394
                    [afaErtek] => 106
                    [bruttoErtek] => 500
                    [megjegyzes] => SimpleXMLElement Object
                        (
                        )

                )

        )

)

In this case I need to remove the element with the azonosito = vpszettkutyszig-30-bundle which is working.

Array
(
    [0] => SimpleXMLElement Object
        (
            [megnevezes] => Fencee Mini M03 Villanypásztor Készülék 0,3 J
            [azonosito] => fenceeminiM03
            [mennyiseg] => 1
            [mennyisegiEgyseg] => SimpleXMLElement Object
                (
                )

            [nettoEgysegar] => 22826.77
            [afakulcs] => 27
            [nettoErtek] => 22826.77
            [afaErtek] => 6163
            [bruttoErtek] => 28989.77
            [megjegyzes] => SimpleXMLElement Object
                (
                )

        )

    [1] => SimpleXMLElement Object
        (
            [megnevezes] => Farmline Villanypásztor Gyűrűszigetelő, 1 db,
            [azonosito] => farmlinegyuruszig
            [mennyiseg] => 25
            [mennyisegiEgyseg] => SimpleXMLElement Object
                (
                )

            [nettoEgysegar] => 51.1812
            [afakulcs] => 27
            [nettoErtek] => 1279.53
            [afaErtek] => 345
            [bruttoErtek] => 1624.53
            [megjegyzes] => SimpleXMLElement Object
                (
                )

        )

    [2] => SimpleXMLElement Object
        (
            [megnevezes] => Villanypásztor Földelő rúd profil, hossza 100 cm, horganyzott
            [azonosito] => foldrud100
            [mennyiseg] => 1
            [mennyisegiEgyseg] => SimpleXMLElement Object
                (
                )

            [nettoEgysegar] => 3141.73
            [afakulcs] => 27
            [nettoErtek] => 3141.73
            [afaErtek] => 848
            [bruttoErtek] => 3989.73
            [megjegyzes] => SimpleXMLElement Object
                (
                )

        )

    [3] => SimpleXMLElement Object
        (
            [megnevezes] => Fence Guard ECONOMY MINI Villanypásztor Vezeték  100 m, 2mm, 3 vezetőszál - 40Kg - 14,4 Ω/m
            [azonosito] => economymini100m
            [mennyiseg] => 1
            [mennyisegiEgyseg] => SimpleXMLElement Object
                (
                )

            [nettoEgysegar] => 1488.19
            [afakulcs] => 27
            [nettoErtek] => 1488.19
            [afaErtek] => 402
            [bruttoErtek] => 1890.19
            [megjegyzes] => SimpleXMLElement Object
                (
                )

        )

    [4] => SimpleXMLElement Object
        (
            [megnevezes] => MPL Házhozszállítás
            [mennyiseg] => 1
            [mennyisegiEgyseg] => SimpleXMLElement Object
                (
                )

            [nettoEgysegar] => 394
            [afakulcs] => 27
            [nettoErtek] => 394
            [afaErtek] => 106
            [bruttoErtek] => 500
            [megjegyzes] => SimpleXMLElement Object
                (
                )

        )

)

But the returned $xml always contains the original array.
Thanks for the help.

Got error ‘PHP message: PHP Parse error: syntax error, unexpected ‘Config’ (T_STRING) on line 19 [duplicate]

AH01071: Got error ‘PHP message: PHP Parse error: syntax error, unexpected ‘Config’ (T_STRING) in /pay/enot_end.php on line 19′

<?php

    include "enot/config.php";
    
    $MERCHANT_ID = Config::merchant_id;
    $SECRET_WORD = Config::secret_key;
    $ORDER_AMOUNT = $_REQUEST['amount'];
    $ORDER_ACCOUNT = $_REQUEST['custom_field'];
    $PAYMENT_ID = $_REQUEST['merchant_id'];
    
    $sign = md5($MERCHANT_ID.':'.$ORDER_AMOUNT.':'.$SECRET_WORD.':'.$PAYMENT_ID);
    $link = mysqli_connect(Config::host, Config::user, Config::pass, Config::base);
    
    if(!$link)
        die('Error Connect: ' . mysqli_error());
    
    if($sign != $_REQUEST['sign_2']) 
        die('bad sign!');
    
    $sql = "UPDATE `"Config::t_account"` SET `"Config::t_account_name"`="Config::t_account_donate"+".$amount." WHERE "Config::t_account"='".$ORDER_ACCOUNT."'";
    
    if(mysqli_query($link, $sql)) 
        echo "Records were updated successfully.";
    else echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
    
    mysqli_close($link);
    
    echo "Good";
?>

Should be modern web page based on JS covered sessions by PHP?

I do not know if in modern web pages is still needed to made for example fields values storage also via JS and PHP? I am just interesting about your opinions.

Bcz course which I absolved was based on theory that everything (what can be) must be first done via PHPand then JS. But course is from 2015.

I know that protecion like sanitization of data must be double checked due to safety if someone turn off JS ~(maybe also this can be covered just by htmlcharspecial function).

But it is still needed to count that someone will use browser with JS turned off also for sessions, validation, etc?

Thank you,