PHP首先执行表单action="<?php $_SERVER['PHP_SELF'];祝辞


php executes first with form action="<?php echo $_SERVER['PHP_SELF']; ?>

php首先执行form action="它不会等待'form action=' from html…怎么了?

<?php
if(isset($_POST['submit']))
{
    $name = $_POST['name'];
    echo "User Has submitted the form and entered this name : <b> $name </b>";
    echo "<br>You can use the following form again to enter a new name.";
}
?>

from my .htaccess。也许它在刹车

## Turn on and setup apache rewrite ##
RewriteEngine On
Options +Followsymlinks
RewriteBase /
## Dissable directory indexing ##
Options -Indexes
## Remove trailing slash from end of uri ##
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1'.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=301,L]
# Redirect to non.php extension
RewriteCond %{THE_REQUEST} ^GET' /([^/]+/)*[^.]+'.php('?[^' ]*)?' HTTP/
RewriteRule ^(([^/]+/)*[^.]+)'.php$  $1 [R=301,L]
## Rewrite Rules ##
RewriteRule ^([0-9-a-z-A-Z-_]+)/?$ goto.php?id=$1 [L]
RewriteRule ^account/(.*)$  $1.php [L]

http://php.net/manual/pt_BR/reserved.variables.server.php

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"><form action="" method="post">相等,因为$_SERVER['PHP_SELF']在执行时返回脚本名称,action=""也提交到执行时的页面。

检查POST的正确方法是:

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
   ... a POST has occurred ...
}

检查特定的字段名是不可靠的——您可能更改了字段名而忘记更新if(),该字段可能被排除,等等……上面的代码是100%可靠的,因为它不依赖于表单本身的任何东西,除了提交方法。