phphtmlhttp-postredbean

HTML form doesn't send POST request


I'm trying to send a post request to itself file from an html form and it doesn't get any data, but at the same time, it works when I do post request via Desktop app Postman. Every click on the submit button just refreshes the page and nothing happens, I also tried to check data with php//input and $_request, none of them get any data. Don't know but it's possible that problem appeared after adding https to the server, I also tried to send a request to different paths /panel and https://mysite/panel.html Thank you for any help!

my 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>

my .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/$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 ^.*$ $0.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]

Solution

  • Yes, I was right, the problem was in https, solved by setting action="" parameter with https://mysite/panel ( without .html )