Problems with passing form details in PHP using POST
This is a piece of code on home.php
<form action="./Login" method="post">
Email Address: <br />
<input type="text" name="username" tabindex="1" /&g开发者_JAVA百科t;<br />
Password: <br />
<input type="password" name="password" tabindex="2" /><br />
<input type="hidden" name="home" value="yes" />
<div class="options">
<input type="submit" value="" name="LoginCheck" class="submit_n" />
</div>
</form>
On submitting isset($_POST['LoginCheck'])
on login.php
return false.
I usually write the form part & processing part on the same file & then this seems to work correctly. However for this case i.e processing on other page this does not seem to work.
This is probably a minor problem but what am I doing wrong?
No value for the LoginCheck
submit input. Per PHP docs isset
"Determine if a variable is set and is not NULL"
I got this working. I have no clue why this worked? Kindly Explain!!
By default all directory access is to index.php [As configured by me in Apache]
So when I say action="./Login" it would go the index.php but for some reason wont remember where it cam from so the POST data isn't there.
I changed it to action="./Login/index.php" & now everything works fine. WHY??????
I think there should be written action="../login.php" instead action="./login.php"
The answer is simple:
Remove the value=""
Web browsers are not required to submit controls that don't have values:
If a control doesn't have a current value when the form is submitted, user agents are not required to treat it as a successful control.
--HTML4 spec, Section 17.13.2 Successful Controls
To clarify, web browsers are required to submit only successful controls, meaning that if the browser opted not to treat the control as successful, the browser can't submit the control.
A successful control is "valid" for submission.
--HTML4 spec, same section as above
What basically happens is that because you have the value of "LoginCheck" set to "", which is NOTHING, the browser doesn't even send it.
I think if you do a print_r($_POST), you won't even see there as an array key, which is why your isset() fails.
Give it a proper value if you want to do something with it.
精彩评论