php – COMO VERIFICAR SE HÁ UMA INFORMAÇÃO NO BANCO DE DADOS E SÓ PERMITIR SUBMIT SE EXISTIR

OLÁ, ESTOU DESENVOLVENDO UM SISTEMA DE PEDIDOS E TENHO DUAS TABELAS PARA ESSA PERGUNTA:
“tabela.pedido” que será a qual será enviado todas informações sobre produto, peso, preço etc. e a “tabela.produto” que fica salvo os produtos, os quais irá ter que conferir se existem, enfim, gostaria que quando for dar o SUBMIT, conferir se existe o produto na ‘tabela.produto’ e se existir, enviar para a ‘tabela.pedido’.
Código HTML:

<form method="post">
    <tr><td><input type="text" name="obs1" placeholder="Observações do produto (opcional)" style="border-radius: 20px; width: 100%;" /></td>
                <td><input type="text" name="produto1" placeholder="Produto" list="produto" style="border-radius: 20px;" required/></td>
                    <datalist id="produto">
                    <select name="select_niveis_acesso">
                        <?php
                            $result_niveis_acessos = "SELECT * FROM tabela.produto";
                            $resultado_niveis_acesso = mysqli_query($conn, $result_niveis_acessos);
                            while($row_niveis_acessos = mysqli_fetch_assoc($resultado_niveis_acesso)){ ?>
                                <option value="<?php echo $row_niveis_acessos('produto'); ?>"><?php echo $row_niveis_acessos('id'); ?></option> <?php
                            }
                        ?>
                    </datalist>
                    </select><br><br>    
            <td><input type="number" step=".01" name="qnt" class="somar" placeholder="Quantidade | KG" style="border-radius: 20px;" required/></td>
            <td><input type="number" step=".01" id="unt" class="somar" name="valor" placeholder="Valor 

    unitário | R$" style="border-radius: 20px;" required/></td></tr>
    <input type="submit" name="acao"></form>

O que precisamos verificar se existe em ‘tabela.produto’ existe o (name=produto1), e se não existir, dar algum tipo de erro.
Meu código PHP:

<?php


$pdo = new PDO('mysql:host=localhost;dbname=planiin','root','');


if(isset($_POST ('acao'))){

$obs1= $_POST('obs1');
$produto1= $_POST('produto1');
$qnt= $_POST('qnt');
$valor= $_POST('valor');

$sql = $pdo->prepare("INSERT INTO `tabela.pedido` VALUES (null,?,?,?,?)");
$sql->execute(array($obs1,$produto1,$qnt,$valor));

echo "<script>alert('Pedido enviado com Sucesso!');";
}
?>

8 – How to prevent image/file deletion from a configForm if don’t press on submit button?

I created a custom config Form in drupal 8, and this form have a managed_file field for upload a logo, the problem is that i set all fields, upload my image and fill other fields, press save, and in this point everything works normal. But if i press on “Delete” button of the image, my file is automatically deleted from my file directory and i have not saved the changes to my form yet.

so in my config still saved a fid of my deleted file. But the file was deleted before save my config form so if i update the page without save not matters, my file was deleted.

Any ideas for control this event to prevent this deletion if i don’t save the configuration Form?

my_module/src/Form/CustomForm.php

<?php

namespace Drupalmy_moduleForm;

use DrupalCoreFormConfigFormBase;
use DrupalCoreFormFormStateInterface;
use DrupalfileEntityFile;

/**
 * Class CustomizationForm.
 */
class CustomForm extends ConfigFormBase {

  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return (
      'my_module.custom',
    );
  }

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'custom_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this->config('my_module.custom');

    $form('menu_logo') = (
      '#type' => 'managed_file',
      '#title' => $this->t('Menu logo'),
      '#upload_validators' => (
        'file_validate_extensions' => ('png jpg jpeg'),
        'file_validate_size' => (25600000),
      ),
      '#theme' => 'image_widget',
      '#preview_image_style' => 'medium',
      '#upload_location' => 'public://',
      '#default_value' => $config->get('menu_logo'),
      '#required' => TRUE,
    );
    $form('splash_screen') = (
      '#type' => 'managed_file',
      '#title' => $this->t('Splash screen'),
      '#upload_validators' => (
        'file_validate_extensions' => ('png jpg jpeg'),
        'file_validate_size' => (25600000),
      ),
      '#theme' => 'image_widget',
      '#preview_image_style' => 'medium',
      '#upload_location' => 'public://',
      '#default_value' => $config->get('splash_screen'),
    );
    $form('theme') = (
      '#type' => 'select',
      '#title' => $this->t('Theme'),
      '#title_display' => 'invisible',
      '#options' => ('dark' => $this->t('Dark theme'), 'light' => $this->t('Light theme')),
      '#default_value' => $config->get('theme'),
    );

    $form('#attached')('library') = (
      'my_module/customization_form',
    );

    $buildForm = parent::buildForm($form, $form_state);
    $buildForm('#theme') = 'customization_form';

    return $buildForm;

  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);

    $this->config('my_module.custom')
      ->set('menu_logo', $form_state->getValue('menu_logo'))
      ->set('splash_screen', $form_state->getValue('splash_screen'))
      ->set('theme', $form_state->getValue('theme'))
      ->save();

    if (!empty($images)) {
      foreach ($images as $image) {
        $file = File::load($image(0));
        $file_usage = Drupal::service('file.usage');
        $file->setPermanent();
        $file->save();

        $file_usage->add($file, 'my_module', 'file', $file->id());
      }
    }

  }

}

No URLs to submit, project on pause for 5 minutes. I need your help again

I couldn’t sleep for two days and started a new project on another computer to solve it, but I still see the same problem.Please help me solve the problem.

No URLs to submit, project on pause for 5 minutes(I’ve been working all night trying to solve it) — 👉 GSA SEO and Marketing Forum 👈

1.Delete and reinstall all programs 10 times

2. Delete link list and download again and import (link list from Asia Virtual Solution)

3.Using 100 semi-proxies.

4. x evil,captcha breaker using

5.WINDOWS SERVER 2019

AMD THREADRIPPER 3960X 24 – CORE

RAM 128GB

6. 7 tier data packs purchased from Asia Virtual Solution
 tier1 and tier1-1 working but The rest The other five are not submit.

I’ve been working all night trying to solve it for three days.

Please help me.

Thank you.

csrf – JWT refresh tokens and Double Submit Cookies

I am struggling to implement JWT refresh tokens with the Double Submit Cookies method.

My current set up for a browser based webapp without refresh tokens looks like this:

  • Upon successful login, API server returns JWT with expiry in a httponly cookie
  • Client server intercepts this and creates httponly cookie copying the jwt values from the header (need to do this as using node-fetch)
  • On each page request, client server reads httponly cookie, passing jwt value to page as a csrf variable. Meta tag is populated with this (for ajax to access), and hidden form values also pick up this so that they can also pass up csrf token in submit post requests.
  • Ajax request setup accesses the meta tag and creates a custom Authorization header with Bearer Token set to the csrf value. Upon ajax execution, api server now receives jwt in httponly cookie, and also the bearer token csrf value, and compares for equality.
  • Normal form request passes up form values to client server, where the csrf hidden form value is added to a custom authorization header as a bearer token, and this is passed up to api server, along with http only cookie. Once again, values are compared before access is granted.

So, I think current set up is working well, but I now want to add refresh tokens, to prevent user getting logged out during session. However, I can’t see how to do this whilst following the Double Submit Cookie approach.

I think a refresh token API request would work similarly to above in terms of CSRF. The access token would now be very short lived, so I assume we could drop the csrf requirement for that, and just have csrf token for the longer lived refresh token. That means that the csrf check would only happen on the API refresh token requests (let me know, though, if you think this is problematic. Maybe I need two CSRF token values per page)

With this in mind, I see the following problem for ajax requests.

  • Upon ajax resource request failure due to access token expiry, fire an ajax refresh token request up to api server. Include refresh csrf token value in auth header so it can be compared against refresh token stored in httponly cookie (all very similar to current set up)
  • Following successful refresh request, receive both the new access token , and a new request token in httponly cookies.
  • Ajax Request is now performed with new access token (no csrf check?), and everything goes fine.
  • However, user stays on the same page, and then finally sends another resource request, but once again, the token has expired…
  • This time, the refresh token request will fail as it will attempt to use the old csrf token metadata value to populate the authorization header, and the comparison on the API server will fail.

So the problem is with Ajax requests: there is no opportunity to update the on-page csrf token after a successful refresh token request.

Are JWT refresh tokens broken because of this, or am I missing something in my set up?

8 – Fire custom submit handler in form embedded in node edit form

I have a form that is being inserted inside of a node edit form and the inserted form is given a custom submit handler. The inserted form’s submit button is defined as follows:

    $form('decision_select')('update') = (
      '#type' => 'submit',
      '#value' => $this->t('Select Segment Set'),
      '#submit' => (($this, 'updateSegmentSet')),
      '#limit_validation_errors' => (),
      '#ajax' => (
        'callback' => ($this, 'updateSegmentSetAjax'),
        'wrapper' => $wrapper_id,
      ),
    );

However, when I click ‘Select Segment Set’ the entire node form is submitted to the backend (I’ve verified this by printing the request/route objects sent to the backend). Is there any way to press that submit button and have only the inserted form sent to the backend along with this custom submit handler? The idea is to have this inserted form filled with values given to it via ajax before the node form is ever submitted to save the node.

8 – Node edit form with embedded form not executing custom submit handler

I’m porting a module that currently works with Blocks/BlockForms to Paragraphs/NodeForms. I’m inserting an embedded form inside a Paragraph inside a Node Edit page using a
hook_field_widget_entity_reference_paragraphs_form_alter. The general structure where the form gets inserted is:

$form['field']['widget'][0]['settings'][form here]

After this the form displays as expected on the node edit page.

The inserted form goes through a number of #process steps. The element in question is a select form that when the button underneath it is pressed, is supposed to retrieve some data via a custom submit handler and place it on the page with ajax:

enter image description here

The array for this element looks like this:

enter image description here

You can see the custom submit handler that is supposed to fire when ‘Select Segment Set’ is pressed

After debugging, I’ve found that the entire NodeForm appears to be submitted to the backend, and the only handler that is found is from some other field that uses ajax. In short ‘updateSegmentSet’ is never discovered as a submit handler. When I debug the original module based on block/blockforms, I do see the correct submit handler being discovered. Now in the latter case, of course a blockForm is submitted to the back end with the correct plugin. Given that this is basically a form within a form within a form, is there something special I have to do to get the custom submit handler to run? I’ve read a few things online e.g. the ‘settings’ key and ‘#tree’ = true.

php – Como faço para recuperar qual submit foi utilizado num formulário?

Tenho esse php ( que vai listar todos itens do meu banco de dados ).

index.php

    <section>
        <div>
            <h1>Produtos</h1>

            <div id="Produtos">
                <?php include 'itens.php';?>
            </div>

            <form action="add/index.php">
                <input type="submit" value="Adicionar Produto">
            </form>
        </div>
    </section>

itens.php

session_start();
include("class/connection.php");
$query = "SELECT * from products";
$result = mysqli_query($conexao, $query);
$row = mysqli_num_rows($result);

for($i = 0; $i < $row; $i++){
    $dado = mysqli_fetch_array($result);
    $idproduct = $dado('idproduct');
    $nome = $dado('nome');
    $preco = $dado('preco');
    $quantia = $dado('quantia');
    echo "<form action='action.php' method='POST'>";
    echo $nome;
    echo "<input type='submit' value='Apagar'>";
    echo "</form>";
}

Fica assim:
inserir a descrição da imagem aqui

Eu queria saber como posso linkar o botão de apagar ao item.

8 – content edit submit handlers do not work for Migrated Content

I have my site in Drupal 7 and have successfully migrated all the contents to D9 (Can view them properly with all the custom fileds added to them. etc..)

There were a couple of original Drupal content types (like basic page and article) already there.

Now the problem:
When I try to preview or submit any original Drupal content types (article or basic page). everything goes fine and I can preview or submit the content.

However, if I try the same (edit and preview or submit) on any of my migrated contents, nothing happens. Page does not change
Incedently I see this error in the logs

Referrer http://mysiteurl/node/preview/52687595-af84-4c53-85ff-3c1cd89747bf/full
Message SymfonyComponentRoutingExceptionResourceNotFoundException: No routes found for “/history//read”. in DrupalCoreRoutingRouter->matchRequest() (line 112 of /var/www/myrootdir/public_html/d9dev/core/lib/Drupal/Core/Routing/Router.php).

Are these things related?
How do I proceed to achieve the preview/submit ability on my migrated contents?

Please guide me.
Thanks in advance

8 – How to add a throbber to a submit button in a form?

In a custom module, I have a form with a simple submit button:

$form('submit') = (
  '#type'   => 'submit',
  '#value'  => $this->t('Submit'),
);

As the execution of the code in submitForm may last for a while, I’d like to add a throbber to this button.
So I updated the code to:

$form('submit') = (
  '#type'  => 'submit',
  '#value' => $this->t('Submit'),
  '#ajax'  => (
    'callback' => '::ajaxCallback',
    'progress' => (
      'type'    => 'throbber',
      'message' => $this->t('Be patient'),
    ),
  ),
);

and in my ajaxCallback, I have nothing as I just want the throbber to be displayed during the execution of the submitForm.
When I click the submit button, I get the throbber but no more validation of the form (validateForm) nor execution of the submitForm.
What am I doing wrong?