PHP Forum

PHP Forum (http://www.selfphp.de/forum/index.php)
-   PHP Grundlagen (http://www.selfphp.de/forum/forumdisplay.php?f=12)
-   -   Pfad für das Formular action Attribut (http://www.selfphp.de/forum/showthread.php?t=25124)

Auf der Mauer 02.12.2013 21:35:21

Pfad für das Formular action Attribut
 
Hallo,

kann mir jemand sagen, welche der drei folgenden Methoden am Besten ist
um den aktuellen Skriptpfad zu ermitteln.

PHP-Code:


// Methode 1
$path htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES"UTF-8");

// Methode 2
$path $_SERVER['SCRIPT_NAME'];

// Methode 3
$path "./" basename(__FILE__); 

Die Letzte gefällt mir eigentlich am Besten, woher kommt denn die Information
für diese magische Konstante?


HTML-Code:

<form method="post" action="<?php echo $path; ?>">

Gruß
Auf der Mauer

DokuLeseHemmung 02.12.2013 21:42:42

AW: Pfad für das Formular action Attribut
 
HTML-Code:

<form method="post" action="">
Oder
HTML-Code:

<form method="post" action="?">
HTML5:
HTML-Code:

<form method="post" >

Auf der Mauer 02.12.2013 22:49:24

AW: Pfad für das Formular action Attribut
 
Hallo,

danke für die Antworten.
Ich fand folgendes dazu.

Zitat:

HTML5 does not allow action=""
und

Zitat:

This definitely works in all current browsers, but may not work as expected in some older browsers ("browsers do weird things with an empty action="" attribute"
Ich dachte daher, es wäre nicht verkehrt einen Pfad anzugeben.
Sicher ist sicher.

Gruß
Auf der Mauer

DokuLeseHemmung 02.12.2013 23:07:34

AW: Pfad für das Formular action Attribut
 
Zitat:

Ich dachte daher, es wäre nicht verkehrt einen Pfad anzugeben.
Wie auch immer, eine Notwendigkeit besteht nicht.

Wobei PHP_SELF XSS Attacken erlauben kann, und damit aus dem Rennen ist.

Auf der Mauer 02.12.2013 23:09:46

AW: Pfad für das Formular action Attribut
 
Zitat:

Zitat von DokuLeseHemmung (Beitrag 145779)
Wobei PHP_SELF XSS Attacken erlauben kann, und damit aus dem Rennen ist.

Aber doch nicht in der oben unter Methode 1 geschriebenen Variante, oder?

Gruß
Auf der Mauer

sysop 03.12.2013 09:57:23

AW: Pfad für das Formular action Attribut
 
Doch eingeschränkt auch da, ausserdem macht htmlspecialchars bei Umlauten Probleme.


Alle Zeitangaben in WEZ +2. Es ist jetzt 09:10:50 Uhr.

Powered by vBulletin® Version 3.8.3 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.