I'm trying to build a simple login system using <form method="post">
. Everything works fine on MAMP on my laptop but when I upload the script to the server (Windows) it doesn't work; it seems that the $_POST array is empty.
I commented out everything but the bare bones and it still doesn't work.
index.php:
<form id="login-form" method="POST" action="_scripts/check_login.php">
Email Address
<input name="login-email" type="text" id="login-email">
Password
<input name="login-password" type="text" id="login-password">
<input type="submit" name="Submit" id="login-button" value="Login">
</form>
_scripts/check_login.php: (I've removed everything except some var_dumps for debugging)
var_dump($_POST);
$loginEmail = trim($_POST['login-email']);
echo '<br>';
$loginPassword = ($_POST['login-password']);
var_dump($loginEmail);
echo '<br>';
var_dump($loginPassword);
When I submit the form, no matter what I put in the text fields, I see this:
array(0) { }
string(0) ""
NULL
If I change all the instances of "post" to "get" in the above two files, everything works fine. But I don't want to use get. ($_REQUEST doesn't work either if I submit the form using method="post").
NB this all works fine on localhost, but not on the server (which is running Windows.) So it would seem to be a problem with the server, but I have no idea what. You can see the PHPInfo here: http://brailleapps.org/phpinf0.php
Any ideas?
EDIT: Solved! See below.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…