HTML 表单未发送 POST 请求
HTML form doesn't send POST request
我正在尝试从 html 表单向自身文件发送 post 请求,但它没有获得任何数据,但与此同时,当我执行 post 通过桌面应用程序 Postman 请求。每次点击提交按钮只会刷新页面,没有任何反应,我还尝试使用 php//input 和 $_request 检查数据,其中 none 获取任何数据。不知道,但有可能在服务器上添加https后出现问题,我也尝试将请求发送到不同的路径/面板和https://mysite/panel.html谢谢你的帮助!
我的page.html
<?php
require 'db.php';
$data = $_POST;
if( isset($data['email']) ){ //PHP stops here, because var_dump($data); is always empty array
$user = R::findOne('users', 'email = ?', array($data['email']));
if( $user ){
if( $data['password'] == $user->password){
$_SESSION['logged'] = $user;
echo '<div class="black">Добро пожаловать в админ-панель</div><br>';
}else{
echo '<div class="black">Не верный пароль</div><br>'; //wrong password
echo $user->password;
}
}else{
echo '<div class="black">Не верный email</div><br>'; //wrong email
}
}
if($_SESSION['logged'])
{
?>
//some html content
<?php
} else {
?>
<div class="p-x-1 p-y-3">
<form class="card card-block m-x-auto bg-faded form-width" action="https://mysite/panel.html" method="post">
<legend class="m-b-1 text-xs-center">Авторизация</legend>
<div class="form-group input-group">
<span class="input-group-addon">@</span>
<span class="has-float-label">
<input class="form-control" name="email" type="email" placeholder="name@example.com" required>
<label for="email">E-mail</label>
</span>
</div>
<div class="form-group has-float-label">
<input class="form-control" name="password" type="password" placeholder="••••••••" required>
<label for="password">Пароль</label>
</div>
<div class="text-xs-center">
<input class="btn btn-block btn-primary" type="submit" name="do_login" value="Войти">
</div>
</form>
</div>
<?php
}
?>
<script src="js/jquery-1.11.0.min.js"></script>
<script src="js/panel.js"></script>
</body>
</html>
我的.htaccess
RewriteEngine On
# Выполняем PHP в html файлах
AddHandler fcgid-script .php .phtml .html .htm
FCGIWrapper /var/www/u0475852/data/php-bin/php .php
FCGIWrapper /var/www/u0475852/data/php-bin/php .phtml
FCGIWrapper /var/www/u0475852/data/php-bin/php .html
FCGIWrapper /var/www/u0475852/data/php-bin/php .htm
# редирект с www
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule ^(.*)$ http://%1/ [L,R=301]
# Делаем редирект со слешем на без слеша
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [R=301,L]
# Убираем html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^.*$ [=13=].html [L,QSA]
RewriteCond %{THE_REQUEST} ([^\s]*)\.html(\?[^\s]*)?
RewriteRule (.*) %1 [R=301,L]
# Редирект с http на https
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
是的,我是对的,问题出在 https 中,通过使用 https://mysite/panel 设置 action="" 参数解决(没有 .html )
我正在尝试从 html 表单向自身文件发送 post 请求,但它没有获得任何数据,但与此同时,当我执行 post 通过桌面应用程序 Postman 请求。每次点击提交按钮只会刷新页面,没有任何反应,我还尝试使用 php//input 和 $_request 检查数据,其中 none 获取任何数据。不知道,但有可能在服务器上添加https后出现问题,我也尝试将请求发送到不同的路径/面板和https://mysite/panel.html谢谢你的帮助!
我的page.html
<?php
require 'db.php';
$data = $_POST;
if( isset($data['email']) ){ //PHP stops here, because var_dump($data); is always empty array
$user = R::findOne('users', 'email = ?', array($data['email']));
if( $user ){
if( $data['password'] == $user->password){
$_SESSION['logged'] = $user;
echo '<div class="black">Добро пожаловать в админ-панель</div><br>';
}else{
echo '<div class="black">Не верный пароль</div><br>'; //wrong password
echo $user->password;
}
}else{
echo '<div class="black">Не верный email</div><br>'; //wrong email
}
}
if($_SESSION['logged'])
{
?>
//some html content
<?php
} else {
?>
<div class="p-x-1 p-y-3">
<form class="card card-block m-x-auto bg-faded form-width" action="https://mysite/panel.html" method="post">
<legend class="m-b-1 text-xs-center">Авторизация</legend>
<div class="form-group input-group">
<span class="input-group-addon">@</span>
<span class="has-float-label">
<input class="form-control" name="email" type="email" placeholder="name@example.com" required>
<label for="email">E-mail</label>
</span>
</div>
<div class="form-group has-float-label">
<input class="form-control" name="password" type="password" placeholder="••••••••" required>
<label for="password">Пароль</label>
</div>
<div class="text-xs-center">
<input class="btn btn-block btn-primary" type="submit" name="do_login" value="Войти">
</div>
</form>
</div>
<?php
}
?>
<script src="js/jquery-1.11.0.min.js"></script>
<script src="js/panel.js"></script>
</body>
</html>
我的.htaccess
RewriteEngine On
# Выполняем PHP в html файлах
AddHandler fcgid-script .php .phtml .html .htm
FCGIWrapper /var/www/u0475852/data/php-bin/php .php
FCGIWrapper /var/www/u0475852/data/php-bin/php .phtml
FCGIWrapper /var/www/u0475852/data/php-bin/php .html
FCGIWrapper /var/www/u0475852/data/php-bin/php .htm
# редирект с www
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule ^(.*)$ http://%1/ [L,R=301]
# Делаем редирект со слешем на без слеша
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [R=301,L]
# Убираем html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^.*$ [=13=].html [L,QSA]
RewriteCond %{THE_REQUEST} ([^\s]*)\.html(\?[^\s]*)?
RewriteRule (.*) %1 [R=301,L]
# Редирект с http на https
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
是的,我是对的,问题出在 https 中,通过使用 https://mysite/panel 设置 action="" 参数解决(没有 .html )