I’ve been having this problem for a while, this is the code for my form:
<form action="site/Main.php" method="post">
<p><label for="user" style="text-indent:415px;">User</label> <input type="text" name="user" /></p>
<p><label for="password">Password</label> <input type="password" name="password" /></p>
<p class="submit"><input type="submit" value="log in" /></p>
</form>
this form is at my admin.php page and I want to pass the variables “user” and “password” to my site/main.php page, however, when I try to access the variables php tells me it they do not exist, this is the code I have on my site/main.php page:
<?php
if(isset($_POST)){
if($_POST["user"] == "Project" && $_POST["password"] == "Project2012"){
echo "Welcome!";
} else{
echo "Wrong username or password!";
}
}
?>
And I keep getting the following error:
(!) Notice: Undefined index: user in C:\wamp\www\site\Main.php on line 10
Any idea of why it seems that the $_POST variables are not being sent to my Main page?
Thanks a lot for the help in advance!
It was very strange, but after a few tries, what I did was change:
for:
And it started working, then I changed it back to its original form and it kept working. Thanks everyone for your comments, they all helped me with different ways on checking on my variables, thanks all for the help.