尝试在php中提交表单时禁止访问

时间:2018-04-17 09:49:23

标签: php html xampp

我是php的新手。我有一些实验室工作,我需要在家里做。一个问题必须做一些非常简单的事情,只是为了在另一个php页面中显示平方数字。但这不会发生。我一直在努力解决这个问题。我记得在过去使用xampp的时候我没有这个问题。 每当我尝试提交表单时,我都会得到:



Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server.

If you think this is a server error, please contact the webmaster.

Error 403
127.0.0.1
Apache/2.4.33 (Win32) OpenSSL/1.1.0g PHP/7.2.4




我尝试其他程序,如easyPHP或wampp ..仍然是同样的问题..这是代码:



//prelucrare.php
<?php
$a = $_POST[‘a’];
echo $a * $a;
?>
&#13;
//index.php
<html>
<head></head>
<body>
<form action=”http://localhost:80/prelucrare.php” method=”post”>
    <input type=”text” name=”a”><br>
    <button type=”submit”>Square it</button>
</form>
</body>
</html>
&#13;
&#13;
&#13;

我的httpd-xampp.conf文件:

&#13;
&#13;
#
# XAMPP settings
#

<IfModule env_module>
    SetEnv MIBDIRS "C:/xampp/php/extras/mibs"
    SetEnv MYSQL_HOME "\\xampp\\mysql\\bin"
    SetEnv OPENSSL_CONF "C:/xampp/apache/bin/openssl.cnf"
    SetEnv PHP_PEAR_SYSCONF_DIR "\\xampp\\php"
    SetEnv PHPRC "\\xampp\\php"
    SetEnv TMP "\\xampp\\tmp"
</IfModule>

#
# PHP-Module setup
#
LoadFile "C:/xampp/php/php7ts.dll"
LoadFile "C:/xampp/php/libpq.dll"
LoadModule php7_module "C:/xampp/php/php7apache2_4.dll"

<FilesMatch "\.php$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
</FilesMatch>

#
# PHP-CGI setup
#
#<FilesMatch "\.php$">
#    SetHandler application/x-httpd-php-cgi
#</FilesMatch>
#<IfModule actions_module>
#    Action application/x-httpd-php-cgi "/php-cgi/php-cgi.exe"
#</IfModule>


<IfModule php7_module>
    PHPINIDir "C:/xampp/php"
</IfModule>

<IfModule mime_module>
    AddType text/html .php .phps
</IfModule>

ScriptAlias /php-cgi/ "C:/xampp/php/"
<Directory "C:/xampp/php">
    AllowOverride None
    Order Allow,Deny
    Allow from All
</Directory>

<Directory "C:/xampp/cgi-bin">
    <FilesMatch "\.php$">
        SetHandler cgi-script
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler None
    </FilesMatch>
</Directory>

<Directory "C:/xampp/htdocs/xampp">
    <IfModule php7_module>
    	<Files "status.php">
    		php_admin_flag safe_mode off
    	</Files>
    </IfModule>
    AllowOverride AuthConfig
</Directory>

<IfModule alias_module>
    Alias /licenses "C:/xampp/licenses/"
    <Directory "C:/xampp/licenses">
        Options +Indexes
        <IfModule autoindex_color_module>
            DirectoryIndexTextColor  "#000000"
            DirectoryIndexBGColor "#f8e8a0"
            DirectoryIndexLinkColor "#bb3902"
            DirectoryIndexVLinkColor "#bb3902"
            DirectoryIndexALinkColor "#bb3902"
        </IfModule>
        Require local
        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
   </Directory>

    Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
    <Directory "C:/xampp/phpMyAdmin">
        AllowOverride AuthConfig
        Require local
        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
    </Directory>

    Alias /webalizer "C:/xampp/webalizer/"
    <Directory "C:/xampp/webalizer">
        <IfModule php7_module>
    		<Files "webalizer.php">
    			php_admin_flag safe_mode off
    		</Files>
        </IfModule>
        AllowOverride AuthConfig
        Require local
        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
    </Directory>
</IfModule>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:2)

//prelucrare.php
<?php
$a = $_POST['a'];
$b = $a * $a;
echo $b;
?>

<html>
<head></head>
<body>
<form action="prelucrare.php" method="POST">
<input type="number" name="a"><br>
<button type="submit">Square it</button>
</form>
</body>
</html>

以上代码完美无缺。请更新您的代码,然后重试。