简体   繁体   中英

PHP form not sending data to $_POST

<!DOCTYPE html>
<html>
    <body>
        <form action="test.php" method="post">
            <input name="test" type="text">
            <input type="password" name="data">
            <input type="submit">
        </form>
    </body>
</html>


<?php
    if($_SERVER['REQUEST_METHOD'] == 'POST'){
        $name = $_POST['test'];
        $pass = $_POST['data'];
    }
?>

I am trying to make a simple form in PHP that users will use for login. When using this code, nothing ever gets put inside the $_POST . I am debugging using PHPstorm and I can tell that the request method is definitely POST, but no data is getting passed through. What am I doing wrong?

尝试在form标记的action参数开始时添加一个斜杠。

<form action="/test.php" method="post">

Try to remove "action" from form. It worked for me.

Code: http://nimb.ws/6pXjnz Output: http://nimb.ws/PvuxZs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM