Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
Ponga todas las solicitudes POST y GET en espera, excepto una específica, luego continúe

Solo necesito respuestas de PHP.

Configuración: Servidor Apache y PHP versión 7.4.

Estoy trabajando en un complemento CAPTCHA para WordPress. Con ese propósito, pensé en validar el campo CAPTCHA antes de validar cualquier otra solicitud.

Esto significa que quiero realizar la solicitud CAPTCHA POST antes de que se complete cualquier otro $_REQUEST.

Estas otras solicitudes pueden ser múltiples y no podré manejar sus scripts.

Pensé que detectaría si se había realizado una solicitud POST o GET, y luego quizás llamar a sleep() y realizar mi POST mientras tanto.

El problema es: sleep () pausa todo el script, mientras que solo quiero que se pausen las otras solicitudes POST y GET ...

 if ($_SERVER['REQUEST_METHOD'] === 'POST' OR $_SERVER['REQUEST_METHOD'] === 'GET' AND $_POST["myRequest"]) { // Pause every POST and GET requests apart from $_POST["myRequest"] until $_POST["myRequest"] is performed } else { continue; }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puede usar la sesión y realizar un seguimiento de la solicitud y guardar la solicitud si $_POST['myRequest'] no está presente, luego cargue la solicitud anterior de la sesión o un archivo. Me gusta esto:

 <?php session_start(); if ($_SERVER['REQUEST_METHOD'] === 'POST' OR $_SERVER['REQUEST_METHOD'] === 'GET') { // POST myRequest has been done before if(isset($_SESSION['.my-request.lock'])) { // If present remove it unset($_SESSION['.my-request.lock']); if(isset($_SESSION['my-data.json'])) { $my_prev_request = json_decode( $_SESSION['my-data.json'] ); unset($_SESSION['my-data.json']); } // Process other requests } else { if(isset($_POST['myRequest'])) { $_SESSION['.my-request.lock'] = true; // Do your own thing } else { // No myRequest and no file, save request data to load it after POST myRequest $_SESSION['my-data.json'] = json_encode( $_REQUEST ); } } } else { // Display Error ? continue; }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!