Method post

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : Method post

Re: Method post

par Herve_be » 24 oct. 2023, 16:37

Je ne comprends pas pourquoi ça fonctionnait avant et plus maintenant, je laisse tomber.

Re: Method post

par or 1 » 23 oct. 2023, 16:47

quand cela n'affiche plus :
array(1) { ["Captcha"]=> string(4) "A43E" }

Re: Method post

par Herve_be » 23 oct. 2023, 16:35

Je ne comprends pas comment je peux voir dans le var_dump que la session s'est "déinitialisée".

Re: Method post

par Spols » 23 oct. 2023, 15:39

Déplace ton var_dump($_POST); dans ton code jusqu'à trouver quand il se "désinitialise"

Et met ton session_start() au tout début du code pour éviter les warning parasite

Re: Method post

par Herve_be » 23 oct. 2023, 12:22

Merci de prendre la peine de chercher le problème.
Il ne me semble pas avoir récemment modifié ce script, peut-être une modification des règles php ?
J'ai ajouté le var_dump($_POST);
Voici ce que donne le premier appel

array(0) { }
Warning: Cannot modify header information - headers already sent by (output started at https://www/Aquarium/RVRT/RVosmo.php:2) in https://www/Aquarium/RVRT/RVosmo.php on line 3
Warning: session_start(): Session cannot be started after headers have already been sent in https://www/Aquarium/RVRT/RVosmo.php on line 4
Warning: Undefined variable $_SESSION in https://www/Aquarium/RVRT/RVosmo.php on line 112
Warning: Trying to access array offset on value of type null in https://www/Aquarium/RVRT/RVosmo.php on line 112
Session Captcha 2 :
Post Captcha NOT set

Je complète la zone input par A43E, le module se rappelle lui-même et donne

array(1) { ["Captcha"]=> string(4) "A43E" }
Warning: Cannot modify header information - headers already sent by (output started at https://.www/Aquarium/RVRT/RVosmo.php:2) in https://www/Aquarium/RVRT/RVosmo.php on line 3
Warning: session_start(): Session cannot be started after headers have already been sent in https://www/Aquarium/RVRT/RVosmo.php on line 4
Warning: Undefined variable $_SESSION in https://www/Aquarium/RVRT/RVosmo.php on line 112
Warning: Trying to access array offset on value of type null in https://www/Aquarium/RVRT/RVosmo.php on line 112
Session Captcha 2 :
Warning: Undefined variable $_SESSION in https://www/Aquarium/RVRT/RVosmo.php on line 113
Warning: Trying to access array offset on value of type null in https://www/Aquarium/RVRT/RVosmo.php on line 113
Post Captcha NOT set

On dirait que le session s'est réinitialisée, à quoi cela peut-il être du ?

Re: Method post

par ynx » 23 oct. 2023, 11:09

Bonjour,

Sur la page en ligne, si j'écris "test" dans l'input et que je soumet le formulaire, le haut de page affiche "Post Captcha : test" puis "Post Captcha NOT set".

La variable $_POST['Captcha'] semble donc bien initialisé d'après le premier retour en haut de page.
Il faudrait vérifier le reste du code pour voir si tu as altéré cette variable par erreur.

Re: Method post

par @rthur » 23 oct. 2023, 11:06

Tu peux faire un var_dump($_POST); en début de ta page PHP pour voir ce qu'elle reçoit en $_POST

Method post

par Herve_be » 23 oct. 2023, 10:21

Bonjour,
J'ai un script php qui fonctionnait très bien mais j'ai du faire une gaffe car il ne fonctionne plus, je ne trouve pas l'erreur.
Code partiel concerné du script TestCaptcha.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
</head>
<body>
<form name='Computer' method='post' action='TestCaptcha.php'>
<?php 
if (isset($_POST['Captcha']))
	{
// Script si le captcha a été bien complété : n'est jamais set !?
echo "<br>Post Captcha : ".$_POST['Captcha'];
	}
else
	{
echo "<br>Post Captcha NOT set";
?>
	<br><input type="text" name="Captcha" style="text-align:left; width: 80px;"/>
	<br><input type="submit" style="width: 80px;"/>
<?php
	}
?>
</body>
</html>
Au premier run $_POST['Captcha'] n'est pas initialisé, quand on clique sur le bouton le script s'appelle lui-même et $_POST['Captcha'] devrait être initialisé.
Il doit y avoir quelque chose dans le reste du code (un peu long) qui "déinitialise" $_POST['Captcha'] pouvez-vous m'aider à trouver quoi ?
En d'autres termes qu'est ce qui peut désinitialiser une variable post ?
Le script complet est ici https://www.rudyv.be/Aquarium/RVRT/RVosmo.php
Merci