Trying to pass values through POST to a php file using $http service of angular js does not work [duplicate]

Basically, I’m creating an e-commerce website for a college project. My intent is that when a user clicks on the add to cart button, the name of the book and it’s price gets sent to an external php file which does the job of handling the cart logic. I’m using the $http service of AngularJS to do this but there is some issue.

Here is the basic function logic:

$scope.executefunc = function(name,price){
                    var data = {
                        action: 'setcart',
                        bname: name,
                        bprice: price
                    }

                    $http.post('cart.php',data)
                        .then(function(response){
                            alert(response.data);
                        },function(err){
                            console.error("Error:",err);
                        });
                };
            });

The php file gives me an error saying “Undefined array key ‘bname'(and bprice) in cart.php file”
Here is what the php file looks like:

<?php
session_start();
$name=$_POST['bname'];
$price=$_POST['bprice'];
echo $name;
echo $price;

What can I do here?

I was confused when I understand the function of a MySQL

I was just confused and did not understand its function when calling variables A, B, C or D in calling MYSQL data.
Can you explain this to me about its function when calling data?
Thank you for those of you who are willing to answer basic questions from me because I just started to make a project

calling the code as below

$sql .= " JOIN detail_penilaian b ON a.id_penilaian = b.id_penilaian";
        $sql .= " JOIN pertanyaan c ON b.id_pertanyaan = c.id_pertanyaan";
        $sql .= " JOIN kategori_penilaian_kinerja d ON c.id_kategori = d.id_kategori";
        $sql .= " WHERE a.nik = '$nik' AND d.keterangan = $ha AND a.id_periode = $idper";

HPHP Fatal error: Uncaught Error: Class “IlluminateSupportFacadesRoute” not found in C:xampphtdocsexample-approutesweb.php:15 how can i solvE

HP Fatal error: Uncaught Error: Class “IlluminateSupportFacadesRoute” not found in C:xampphtdocsexample-approutesweb.php:15

I M TRYING TO TOUTE ROUTES WEB.PHP AND I GET AN ERROR 404 NOT FOUND AND THIS HP Fatal error: Uncaught Error: Class “IlluminateSupportFacadesRoute” not found in C:xampphtdocsexample-approutesweb.php:15

php max_execution_time not taked to the account

I have a combination of Nginx and PHP-FPM, and I want to set the max execution time on the PHP level to be the same as on Nginx. So I add max_execution_time=30 but it does not work.
If I create an endpoint with the logic like this:

     foreach (range(1, 50) as $i) {
            sleep(1);
            if ($i > 40) {
                $this->logger->error('Processing request', ['i' => $i]);
                continue;
            }

            if ($i > 20) {
                $this->logger->warning('Processing request', ['i' => $i]);
                continue;
            }

            $this->logger->info('Processing request', ['i' => $i]);
        }

        $this->logger->info('Request processed');

and running that script after 30 seconds I see 504 from Nginx, but PHP still processing the request and writing logs. What I’m doing wrong?

Update: sleep here is just an example, on production for long-running endpoints I also see the same issue, when Nginx already interrupted execution but PHP still processing either, executing some query or something else, and I do not want PHP to be busy if it should not be… I know that can be handled on the FPM side by request_terminate_timeout, it’ll SIGTERM process, but in that case, new issues appearing related to PHP workers respawn that lead to an increased amount of 504 that even not reaching PHP at all, and to fix that you need increase amount PHP child processes, which I do not want to do.

ERR_CERT_REVOKED only on Smartphones (connection is not secure)

My website, which has been running smoothly for more than a year, started having issues as of today. While I can access it without any problems from my computer, when I try to access it from my phone, it gives a ‘connection is not secure’ warning. (NET::ERR_CERT_REVOKED).
I’m in the moment of troubleshooting the issue through trial and error, I deleted the content of the website and used PHP to print(‘text’).

Here is the link to the page: https://t.ly/vdhmu

I contacted the host service and discussed the issue. I asked if there was a problem with the SSL. They said the issue might be related to the website’s source code. Therefore, I temporarily deleted the website’s content.

How to replace string in phpunit.xml in GitHub Actions

I’m encountering an issue with GitHub Actions regarding my job setup. I’m using the following steps in my workflow:

- name: Add secrets to phpunit.xml
  run: |
    sed -i 's/{{SIASN_MODE}}/${{ secrets.SIASN_MODE }}/g' phpunit.xml
    sed -i 's/{{SIASN_APIM_USERNAME}}/${{ secrets.SIASN_APIM_USERNAME }}/g' phpunit.xml
    sed -i 's/{{SIASN_APIM_PASSWORD}}/${{ secrets.SIASN_APIM_PASSWORD }}/g' phpunit.xml
    sed -i 's/{{SIASN_SSO_CLIENT_ID}}/${{ secrets.SIASN_SSO_CLIENT_ID }}/g' phpunit.xml
    sed -i 's/{{SIASN_SSO_USERNAME}}/${{ secrets.SIASN_SSO_USERNAME }}/g' phpunit.xml
    sed -i 's/{{SIASN_SSO_PASSWORD}}/${{ secrets.SIASN_SSO_PASSWORD }}/g' phpunit.xml
    sed -i 's/{{SIASN_CONST_INSTANSI_ID}}/${{ secrets.SIASN_CONST_INSTANSI_ID }}/g' phpunit.xml
    sed -i 's/{{SIASN_CONST_SATUAN_KERJA_ID}}/${{ secrets.SIASN_CONST_SATUAN_KERJA_ID }}/g' phpunit.xml
    sed -i 's/{{SIASN_CONST_PNS_ORANG_ID}}/${{ secrets.SIASN_CONST_PNS_ORANG_ID }}/g' phpunit.xml

While this setup works flawlessly on Linux (https://github.com/kanekescom/laravel-siasn-api/actions/runs/9791401762), it seems to fail on Windows environments. I suspect the issue lies in how the sed command handles line endings or other differences between operating systems.

Here’s the phpunit.xml.dist file I’m attempting to modify, replacing placeholders with values from my secrets repository. How can I adjust my workflow to ensure compatibility across both Linux and Windows environments?

Laravel migration problem with env file maybe

I just started working with Laravel and php and my supervisor just asked me to clone the Laravel repo from git and run it in my computer. the localhost/login page works, but I tried running php artisan migrate, but this occurs.

root@48cc4e852d29:/var/www/html# php artisan migrate

   IlluminateDatabaseQueryException 

  SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_
schema.tables where table_schema = church and table_name = migrations and table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:712
    708▕         // If an exception occurs when attempting to run a query, we'll format the error
    709▕         // message to include the bindings with SQL, which will make this exception a
    710▕         // lot more helpful to the developer instead of just the database's errors.
    711▕         catch (Exception $e) {
  ➜ 712▕             throw new QueryException(
    713▕                 $query, $this->prepareBindings($bindings), $e
    714▕             );
    715▕         }
    716▕     }

      +33 vendor frames 
  34  artisan:37
      IlluminateFoundationConsoleKernel::handle(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))

this is what my .env file looks like

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:Hb5jKxtoJ5Pixeznb9FaaFMwr9/zp+IypWXUg3D8k30=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

and i attached a photo of my database which has the url http://localhost:8081

tried to modify the env file, changed the

DB_PORT=3306 to 8081
DB_DATABASE=laravel to church

but it didn`t do nothing.
what i have to do to solve this?

wordpress payment plugin doesn’t appear

I face a problem with showing a custom payment option in payment options
Iam sure it is set up correctly but it doesn’t appear (like photos)
I also added a js file with some logs to make sure it is working and it did the logs

`<?php

/*
Plugin Name: My Custom Payment Gateway
Description: A custom payment gateway for WooCommerce.
Version: 1.0
Author: Your Name
*/

// Ensure WooCommerce is active
if (in_array(‘woocommerce/woocommerce.php’, apply_filters(‘active_plugins’, get_option(‘active_plugins’)))) {
// Add custom payment gateway class
add_action(‘plugins_loaded’, ‘my_custom_payment_gateway_init’, 5);
function my_custom_payment_gateway_init() {
class WC_Gateway_Custom extends WC_Payment_Gateway {
public function __construct() {
$this->id = ‘custom_gateway’;
$this->icon = ”; // URL to an icon if you want to add
$this->has_fields = true;
$this->method_title = __(‘Custom Gateway’, ‘woocommerce’);
$this->method_description = __(‘Description of custom payment gateway’, ‘woocommerce’);

            // Load the settings
            $this->init_form_fields();
            $this->init_settings();

            $this->title = $this->get_option('title');
            $this->description = $this->get_option('description');

            // Save settings
            add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
        }

        // Admin options
        public function init_form_fields() {
            $this->form_fields = array(
                'enabled' => array(
                    'title' => __('Enable/Disable', 'woocommerce'),
                    'type' => 'checkbox',
                    'label' => __('Enable Custom Payment Gateway', 'woocommerce'),
                    'default' => 'yes'
                ),
                'title' => array(
                    'title' => __('Title', 'woocommerce'),
                    'type' => 'text',
                    'description' => __('This controls the title which the user sees during checkout.', 'woocommerce'),
                    'default' => __('Custom Payment', 'woocommerce'),
                    'desc_tip' => true,
                ),
                'description' => array(
                    'title' => __('Description', 'woocommerce'),
                    'type' => 'textarea',
                    'description' => __('This controls the description which the user sees during checkout.', 'woocommerce'),
                    'default' => __('Pay using our custom payment gateway.', 'woocommerce')
                )
            );
        }

        // Display custom fields on the checkout page
        public function payment_fields() {
            // Description of the payment method
            if ($this->description) {
                echo wpautop(wp_kses_post($this->description));
            }
            // Add custom fields here
            ?>
            <fieldset>
                <p class="form-row form-row-wide">
                    <label for="<?php echo esc_attr($this->id); ?>-custom-field"><?php esc_html_e('Custom Field', 'woocommerce'); ?> <span class="required">*</span></label>
                    <input id="<?php echo esc_attr($this->id); ?>-custom-field" class="input-text" type="text" autocomplete="off">
                </p>
            </fieldset>
            <?php
        }

        // Payment processing
        public function process_payment($order_id) {
            $order = wc_get_order($order_id);

            // Mark as on-hold (we're awaiting the payment)
            $order->update_status('on-hold', __('Awaiting custom payment', 'woocommerce'));

            // Reduce stock levels
            wc_reduce_stock_levels($order_id);

            // Remove cart
            WC()->cart->empty_cart();

            // Return thank you page redirect
            return array(
                'result' => 'success',
                'redirect' => $this->get_return_url($order)
            );
        }
    }
}

// Add to WooCommerce
add_filter('woocommerce_payment_gateways', 'add_my_custom_payment_gateway');
function add_my_custom_payment_gateway($gateways) {
    $gateways[] = 'WC_Gateway_Custom';
    return $gateways;
}

// Enqueue JavaScript file
add_action('wp_enqueue_scripts', 'custom_gateway_enqueue_script');
function custom_gateway_enqueue_script() {
    wp_enqueue_script('custom-gateway-js', plugin_dir_url(__FILE__) . 'custom-gateway.js', array('jquery'), '1.0', true);
}

}
?>`

I watched alot of videos and tutorials but none of help (iam runing it locally if this help)

Reset password link in Laravel does not refer to the specified guard

In my application, there are some guards (i.e. auth, student, teacher). I want to make users from each guard to be able to reset their password. So I made different reset password controllers for each guard. For example, StudentPasswordResetLinkController for student users and TeacherPasswordResetLinkController for teacher users. I also made different routes for each. In each controller, I add Password::broker('guard-name') in store function to specify which users should be referred. It looks something like this.

The student guard routes:

Route::get('/student/forgot-password', [StudentPasswordResetLinkController::class, 'create'])
       ->middleware('guest')
       ->name('student.password.request');
Route::post('/student/forgot-password', [StudentPasswordResetLinkController::class, 'store'])
       ->middleware('guest')
       ->name('student.password.email');

While in the controller:

public function store(Request $request)
{
    $request->validate([
        'email' => 'required|email',
    ]);

    // Student guard
    $status = Password::broker('student')->sendResetLink(
        $request->only('email')
    );

    return $status == Password::RESET_LINK_SENT
                ? back()->with('status', __($status))
                : back()->withInput($request->only('email'))
                        ->withErrors(['email' => __($status)]);
}

With this, student users can receive the email in their email inbox, so I can assume that the application has selected the correct user guard (student instead of teacher or auth). But the problem is, the link sent to the email does not specify which guard should be referred to when it is clicked. The link is like:

http://myapp.local/reset-password?token=xxxxxx

This link took student users to auth instead of student guard so when they insert new password, the new password didn’t work. I expect the link look like this:

http://myapp.local/student/reset-password?token=xxxxxx

Can anyone figure out the solution for this?

Symfony 5.4 Rendering custom template form CollectionField with a custom type

How can I make thus field use the template?

Following the documentation does not seem to help. What am I missing?

I’m trying to render it on this crud controller field:

         $translationContents = CollectionField::new('translationKeys')
            ->setTemplatePath('admin/translation_content.html.twig')
            ->setFormTypeOptions([
                'entry_type' => TranslationType::class,
                'by_reference' => false,
            ]);

This is my custom type:

class TranslationType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name', TextType::class, [
                'label' => 'Key',
            ])
            ->add('translationContent', CollectionType::class, [
                'entry_type' => TranslationContentType::class,
                'label' => false,
                'allow_add' => true,
                'allow_delete' => true,
            ]);
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => TranslationKey::class,
        ]);
    }
    public function getBlockPrefix()
    {
        return 'translation_key';
    }
}

This is the other custom type that renders inside the one before:

class TranslationContentType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('locale', EntityType::class, [
                'class' => Locale::class,
                'choice_label' => 'code', // Assuming your Locale entity has a 'code' property
                'label' => 'Locale',
            ])
            ->add('name', TextType::class, [
                'label' => 'Translation Content',
            ])
            ->add('tag', IntegerType::class, [
                'label' => 'tag',
                'attr' => [
                    'min' => 0,
                    'max' => 3
                ],
            ]);
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => TranslationContent::class,
        ]);
    }
}

this is the template I’m trying to use. Currently is just a way to debug if it’s beeing rendered.

{% block translation_key_widget %}
{{ dump('Template loaded!') }}
    {% for child in form.children|filter(child => not child.rendered) %}
        <div class="form-group">
            <p> test</p>
            {{ form_label(child) }}
            {{ form_widget(child) }}
            {{ form_help(child) }}
            {{ form_errors(child) }}
        </div>
    {% endfor %}
{% endblock %}

I’ve added this to twig.yaml

    form_themes:
        - 'admin/translation_content.html.twig'

Embed External Blob PDF into DomPDF

I am generating PDF using domPDF and addition to that I have some PDF files stored in my database that I want to embed into the PDF that I am generating by using domPDF. So for example:

PDF Files Stored in MySql as Blob

$MysqlPDF = Blob content stored in the mysql database

Generating a PDF using domPDF

$html = '<html>
<body>
Some content to generate pdf 

want to include here the PDF from blob
<div style="page-break-after: always;"></div>

$MysqlPDF

</body>
</html>'
$pdf->loadHtml($html);

When I echo or print $MysqlPDF it is only showing the PDF of $MysqlPDF and not showing the one which I am generating using domPDF. And if I remove $MysqlPDF then it is only showing the PDF content that I am generating using domPDF. So I am not sure what is the best way to embed $MysqlPDF into the PDF generation using domPDF.

How to protect from browser tab creation delivering a PDF file?

I have a website where, after login, people can download personalized PDF documents. There is a specific problem I found no solution or discussion on StackOverflow yet.

First, I deliver the documents with this function (pre headers sent):

function _outputContent(&$fileEntry) {
  // return $fileEntry content (decrypted PDF file)!
  header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  header("Cache-Control: private",false);
  header("Accept-Ranges: bytes");
  header("Pragma: public");
  header('Expires: 0');
  header("Content-Description: File Transfer");
  header("Content-Type: application/pdf");
  header("Content-Disposition: attachment; filename="".$fileEntry["name"].""");
  header("Content-Transfer-Encoding: binary");
  header("Content-Length: " . strlen($fileEntry["decrypted"]));

  echo $fileEntry["decrypted"];
}

The thing is, that mainly on mobile devices, depending on webbrowser, preferences and settings, this opens a new tab in end users webbrowser if the webbrowser displays the PDF directly. If the user later closes the webbrowser and opens it a few hours later, some web browsers try to restore all previous opened tabs and trigger invalid download requests for these tabs. The most requests were 56 requests in three seconds from a single device. Sadly, this triggers mod_evasive and another security tool we implemented against DOS attacks.

Is there a way to deliver the PDF so that there is no download URL staying in the new created tab?

I tried other Content-Type values like application/octet-stream but this triggers issues for end users who want the PDF to be opened directly. Some seem not able to open a downloaded file later on. So it is good that the PDF is displayed immediately. Or can I prevent the webbrowser from creating a new tab at all?

The submenus of my drop-down menu are not displayed on any browser

I develop my site in php with the Laravel framework. Below is the source code for my drop-down menu, however the submenus are not displayed on browsers. What can be the problem ?

<div class="btn-group">
        @guest
          <button type="button" class="btn btn-light dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
            My Account
          </button>
          <ul class="dropdown-menu">
            <li><a class="dropdown-item" href="{{route('login')}}">Login</a></li>
            <li><a class="dropdown-item" href="{{route('register')}}">Register</a></li>
          </ul>
        @endguest

        @auth
          <button type="button" class="btn btn-light dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
            {{Auth::user()->name}}
          </button>
          <ul class="dropdown-menu">
            <li><a class="dropdown-item" href="{{route('app_logout')}}">Logout</a></li>
          </ul>

        @endauth


      </div>

I tried with Firefox, Google Chrome and Microsoft Edge browsers and I still have nothing

Class “BarryvdhDomPDFFacadePDF” Not Found in Laravel 11 When Deploying live

I have a little problem with my project that I don’t know how to fix it. I use a dompdf to generate pdf. everything went well in my local but after I host it this error occur: Class "BarryvdhDomPDFFacadePDF" Not Found

This is how I call it in my controller:

use BarryvdhDomPDFFacadePDF;

and how I use it:

public function generatecustPDF()
    {
        $customers = Customer::get();
    
        $data = [
            'title' => 'Customer List',
            'date' => date('d/m/Y'),
            'customers' => $customers
        ]; 
              
        $pdf = PDF::loadView('Master.Customer.printcustomer', $data);
       
        return $pdf->stream("Customer List.pdf", array("Attachment" => false));
    }