Nilesta Posted October 8, 2007 Share Posted October 8, 2007 Odd problem. I'm making ye olde login page. If I use GET, it works, if I use POST, it doesn't. Here's the code as it is, right now: include 'auth.php'; if (isset($HTTP_POST_VARS['name']) && isset($HTTP_POST_VARS['pass'])){ $UserName = $HTTP_POST_VARS['name']; $Password = $HTTP_POST_VARS['pass']; $Result = Login($UserName, $Password); }else{ $Result = 4; }; and the page: <form method="post" action="login.php"> User Name: <input type="text" name="name"> <BR> Password: <input type="password" name="pass"> <BR> <input type="submit" value="Login"></form> I'm using PHP 5, SQL server 2005, Windows XP. Originally I was using $_POST, instead of the http_post_vars, but I was getting desperate. It still doesn't work. If I take out the method=post, and switch the code to use $_GET, it will work, and log me in. As it is, now, or with using $_POST, it will return result 4 (as if I hadn't typed anything into the field). It doesn't throw an error, it just doesn't think I entered anything into the form. I've looked all over for an answer, but just can't find anyone even having the same issue, or mentioning the same issue. I even tried switching register_globals to on and resetting IIS. Still not working. Really starting to drive me bonkers. Help? Link to comment https://forums.phpfreaks.com/topic/72270-solved-post-variables-apparently-not-working/ Share on other sites More sharing options...
simcoweb Posted October 8, 2007 Share Posted October 8, 2007 You might want to try it this way: include 'auth.php'; if (isset($_POST['submit'])){ $UserName = $_POST['name']; $Password = $_POST['pass']; $Result = Login($UserName, $Password); }else{ $Result = 4; }; Link to comment https://forums.phpfreaks.com/topic/72270-solved-post-variables-apparently-not-working/#findComment-364432 Share on other sites More sharing options...
jellis Posted October 8, 2007 Share Posted October 8, 2007 Odd problem. I'm making ye olde login page. If I use GET, it works, if I use POST, it doesn't. Here's the code as it is, right now: }; and the page: <form method="post" action="login.php"> Perhaps remove the semi-colon after the closing curly brace... and then also add enctype="multipart/form-data" to the form tags. Hope this helps! Link to comment https://forums.phpfreaks.com/topic/72270-solved-post-variables-apparently-not-working/#findComment-364434 Share on other sites More sharing options...
Nilesta Posted October 8, 2007 Author Share Posted October 8, 2007 Thanks for trying, guys. I've tried both suggestions, still not working. :'( Link to comment https://forums.phpfreaks.com/topic/72270-solved-post-variables-apparently-not-working/#findComment-364436 Share on other sites More sharing options...
~n[EO]n~ Posted October 8, 2007 Share Posted October 8, 2007 include 'auth.php'; if (isset($_POST['name']) && isset($_POST['pass'])){ $UserName = $_POST['name']; $Password = $_POST['pass']; $Result = Login($UserName, $Password); }else{ $Result = 4; }; Link to comment https://forums.phpfreaks.com/topic/72270-solved-post-variables-apparently-not-working/#findComment-364439 Share on other sites More sharing options...
Nilesta Posted October 8, 2007 Author Share Posted October 8, 2007 n~ link=topic=162501.msg711784#msg711784 date=1191825113] include 'auth.php'; if (isset($_POST['name']) && isset($_POST['pass'])){ $UserName = $_POST['name']; $Password = $_POST['pass']; $Result = Login($UserName, $Password); }else{ $Result = 4; }; As I mentioned in my post, $_POST was the first thing I tried. It doesn't work. Link to comment https://forums.phpfreaks.com/topic/72270-solved-post-variables-apparently-not-working/#findComment-364442 Share on other sites More sharing options...
~n[EO]n~ Posted October 8, 2007 Share Posted October 8, 2007 try this include 'auth.php'; if($_SERVER['REQUEST_METHOD'] == 'POST') { $UserName = $_POST['name']; $Password = $_POST['pass']; $Result = Login($UserName, $Password); }else{ $Result = 4; }; Link to comment https://forums.phpfreaks.com/topic/72270-solved-post-variables-apparently-not-working/#findComment-364443 Share on other sites More sharing options...
Rithiur Posted October 8, 2007 Share Posted October 8, 2007 I tested this code, and the var_dump printed everything out just nicely for me (using the following code as everything on login.php): <?php if (isset($_POST['name']) && isset($_POST['pass'])){ $UserName = $_POST['name']; $Password = $_POST['pass']; $Result = var_dump($UserName, $Password); }else{ $Result = 4; }; ?> <form method="post" action="login.php"> User Name: <input type="text" name="name"> <BR> Password: <input type="password" name="pass"> <BR> <input type="submit" value="Login"></form> Link to comment https://forums.phpfreaks.com/topic/72270-solved-post-variables-apparently-not-working/#findComment-364445 Share on other sites More sharing options...
Nilesta Posted October 8, 2007 Author Share Posted October 8, 2007 n~ link=topic=162501.msg711788#msg711788 date=1191825802] try this include 'auth.php'; if($_SERVER['REQUEST_METHOD'] == 'POST') { $UserName = $_POST['name']; $Password = $_POST['pass']; $Result = Login($UserName, $Password); }else{ $Result = 4; }; This actually worked. I don't know why, but it did. Thanks! Link to comment https://forums.phpfreaks.com/topic/72270-solved-post-variables-apparently-not-working/#findComment-364455 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.