retour en arrière après execution script

Mammouth du PHP | 702 Messages

11 mai 2012, 08:45

Bonjour à tous, j'aimerais bien qu'après exécution d'une requête, le script fasse un retour en arrière en actualisant la page.
j'ai donc vu qu'avec ce code ci
 <?php
if (isset($_POST['go'])) { 

$sql = 'UPDATE '.$_GET['liasse'].' SET

code_s = "'.mysql_real_escape_string($_POST['code_s']).'",
libelle= "'.mysql_real_escape_string($_POST['libelle']).'",
action= "'.mysql_real_escape_string($_POST['action']).'",
description= "'.mysql_real_escape_string($_POST['description']).'",
date_action= "'.date('Y-m-d',strtotime($_POST['date_action'])).'"

WHERE id='.$_GET['id'].'
' ;
mysql_query($sql) or die(__LINE__.mysql_error().$sql);
header('Location: ' . $_SERVER['HTTP_REFERER']);
  exit;
}
?>
en utilisant le header location àa devait fonctionner mais rien ne se produit (la page qui édite les informations et celle qui traite le formulaire sont les même mais celle ou on clique pour faire les modification est différente. si c'est cela le problème je ne sais pas comment procéder, car il peut considérer que comme on clique, alors on est sur une nouvelle page et que le retour en arrière est la page de modification. (page de traitement et de modification ne sont qu'une page).

Je suis donc bloqu, car il fait rien.

D'avance merci pour votre aide.

Mammouth du PHP | 702 Messages

11 mai 2012, 09:21

j'ai essayé avec cela également [javascript] <?php
if (isset($_POST['go'])) {

$sql = 'UPDATE '.$_GET['liasse'].' SET

code_s = "'.mysql_real_escape_string($_POST['code_s']).'",
libelle= "'.mysql_real_escape_string($_POST['libelle']).'",
action= "'.mysql_real_escape_string($_POST['action']).'",
description= "'.mysql_real_escape_string($_POST['description']).'",
date_action= "'.date('Y-m-d',strtotime($_POST['date_action'])).'"

WHERE id='.$_GET['id'].'
' ;
mysql_query($sql) or die(__LINE__.mysql_error().$sql);
header('Location: '."javascript:history.back(-2)".'');
exit;
}
?>[/javascript]

mais rien n'y fait...

ViPHP
xTG
ViPHP | 7331 Messages

11 mai 2012, 10:39

Ton navigateur renseigne-t-il le HTTP_REFERER ?
Vérifies en affichant l'array $_SERVER.

As-tu activé un niveau correct d'erreur de PHP ?

Mammouth du PHP | 702 Messages

11 mai 2012, 11:20

la première question je ne sais pas,

pour la seconde, oui le niveau d'erreur est correctement activé sur wamp.

je sèche.

ViPHP
xTG
ViPHP | 7331 Messages

11 mai 2012, 11:31

Affiches $_SESSION, sinon c'est sûr que tu vas sécher longtemps...

Mammouth du PHP | 702 Messages

11 mai 2012, 11:34

la variable fonctionne correctement... d'ailleurs j'ai un système de login avec ces variables et redirection sui la personne n'est pas loguée.

ViPHP
xTG
ViPHP | 7331 Messages

11 mai 2012, 11:59

Faute de frappe, je voulais dire $_SERVER.
Il n'y a aucun intérêt à afficher $_SESSION dans ce cas là.

Mammouth du PHP | 702 Messages

11 mai 2012, 16:19

il me répond cela:
array
  'HTTP_HOST' => string 'localhost' (length=9)
  'HTTP_CONNECTION' => string 'keep-alive' (length=10)
  'HTTP_USER_AGENT' => string 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19' (length=109)
  'HTTP_ACCEPT' => string 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' (length=63)
  'HTTP_REFERER' => string 'http://localhost/NEOGETCASH/GESTIONNAIRE/edit-decompte.php?id=1&n_doss=110015666223&code_client=1566' (length=100)
  'HTTP_ACCEPT_ENCODING' => string 'gzip,deflate,sdch' (length=17)
  'HTTP_ACCEPT_LANGUAGE' => string 'fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4' (length=35)
  'HTTP_ACCEPT_CHARSET' => string 'ISO-8859-1,utf-8;q=0.7,*;q=0.3' (length=30)
  'HTTP_COOKIE' => string 'CKFinder_Path=Files%3A%2F%3A1; PHPSESSID=tba0e20tc17qvdk82geqamqhs6' (length=67)
  'PATH' => string 'C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;' (length=143)
  'SystemRoot' => string 'C:\Windows' (length=10)
  'COMSPEC' => string 'C:\Windows\system32\cmd.exe' (length=27)
  'PATHEXT' => string '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC' (length=53)
  'WINDIR' => string 'C:\Windows' (length=10)
  'SERVER_SIGNATURE' => string '' (length=0)
  'SERVER_SOFTWARE' => string 'Apache/2.2.21 (Win64) PHP/5.3.8' (length=31)
  'SERVER_NAME' => string 'localhost' (length=9)
  'SERVER_ADDR' => string '127.0.0.1' (length=9)
  'SERVER_PORT' => string '80' (length=2)
  'REMOTE_ADDR' => string '127.0.0.1' (length=9)
  'DOCUMENT_ROOT' => string 'C:/wamp/www/' (length=12)
  'SERVER_ADMIN' => string 'admin@localhost' (length=15)
  'SCRIPT_FILENAME' => string 'C:/wamp/www/NEOGETCASH/GESTIONNAIRE/agenda.php' (length=46)
  'REMOTE_PORT' => string '49794' (length=5)
  'GATEWAY_INTERFACE' => string 'CGI/1.1' (length=7)
  'SERVER_PROTOCOL' => string 'HTTP/1.1' (length=8)
  'REQUEST_METHOD' => string 'GET' (length=3)
  'QUERY_STRING' => string 'n_doss=110015666223&id=1&code_client=1566' (length=41)
  'REQUEST_URI' => string '/NEOGETCASH/GESTIONNAIRE/agenda.php?n_doss=110015666223&id=1&code_client=1566' (length=77)
  'SCRIPT_NAME' => string '/NEOGETCASH/GESTIONNAIRE/agenda.php' (length=35)
  'PHP_SELF' => string '/NEOGETCASH/GESTIONNAIRE/agenda.php' (length=35)
  'REQUEST_TIME' => int 1336745933

ViPHP
xTG
ViPHP | 7331 Messages

11 mai 2012, 19:52

Donc le premier script devrait fonctionner. Sauf si ce if n'est jamais exécuté ou bien qu'une erreur survient mais que ton affichage des erreurs est désactivée.