mikehershey Posted October 11, 2008 Share Posted October 11, 2008 Hi, My php _POST variable is not working. I have Apache2 AND tomcat could that be causing interference . Here is an example script to make sure im not missing something stupid. <? session_start(); require_once("db.php"); echo print_r($_POST);; if(isset($_POST['username']) && isset($_POST['password'])) { $con = mysql_connect("localhost",$username,$password); if(!(mysql_select_db($database))) die("Server Error"); $result = mysql_query("SELECT * FROM logins WHERE user='".mysql_escape_string($_POST['username'])."' AND pass='".md5(mysql_escape_string($_POST['password']))."'"); if(mysql_num_rows($result)==1) { $title= "logged in"; $_SESSION['user']=$_POST['username']; header ("Location: index.php"); } else { $title ="Username/Password combination is invalid"; } mysql_close($con); } else { $title="You need to log in to use this service"; } ?> <html> <head> <title>Log in</title> </head> <body> <div style="margin-left:auto;margin-right:auto;width:350px;"> <?=$title?> <form action="login.php" method="post"> <p>Username:<input name="username" type="text" maxlength="15"></p> <p>Password:<input name="password" type="password" maxlength="15"></p> <input type="submit"> </form> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/128040-php-_postvarname-does-not-work-in-any-php-page/ Share on other sites More sharing options...
AV1611 Posted October 11, 2008 Share Posted October 11, 2008 put this at the top of your script for a test: if(isset($_POST['password'])){ echo 'PW is set: '.$_POST['password']; }else{echo 'PW not set!';} echo '<br />'; if(isset($_POST['username'])){ echo 'USERNAME is set: '.$_POST['username']; }else{echo 'USERNAME not set!';} Quote Link to comment https://forums.phpfreaks.com/topic/128040-php-_postvarname-does-not-work-in-any-php-page/#findComment-663032 Share on other sites More sharing options...
mikehershey Posted October 11, 2008 Author Share Posted October 11, 2008 I didn't get output from either of those. If i change everything to get it does work. I had the script working on a different server then i moved it and now it doesn't work. Quote Link to comment https://forums.phpfreaks.com/topic/128040-php-_postvarname-does-not-work-in-any-php-page/#findComment-663038 Share on other sites More sharing options...
mikehershey Posted October 11, 2008 Author Share Posted October 11, 2008 here is my server signature Apache/2.2.8 (Ubuntu) mod_jk/1.2.25 PHP/5.2.4-2ubuntu5.3 with Suhosin-Patch Server at 127.0.0.1 Port 80 Quote Link to comment https://forums.phpfreaks.com/topic/128040-php-_postvarname-does-not-work-in-any-php-page/#findComment-663052 Share on other sites More sharing options...
kenrbnsn Posted October 11, 2008 Share Posted October 11, 2008 You seem to be using short tags "<?", try changing them to long tags "<?php". Ken Quote Link to comment https://forums.phpfreaks.com/topic/128040-php-_postvarname-does-not-work-in-any-php-page/#findComment-663054 Share on other sites More sharing options...
mikehershey Posted October 12, 2008 Author Share Posted October 12, 2008 I changed the tags and it made no difference the script executes fine and the output for the printr $_POST is always Array ( ) 1 even when I submit the form. I noticed the double ;; after the printr but that shouldnt matter in the code because it is just executing nothing after printing, and i fixed the typo now (problem still exists). Quote Link to comment https://forums.phpfreaks.com/topic/128040-php-_postvarname-does-not-work-in-any-php-page/#findComment-663159 Share on other sites More sharing options...
kenrbnsn Posted October 12, 2008 Share Posted October 12, 2008 Please show us the form that invokes this script. Ken Quote Link to comment https://forums.phpfreaks.com/topic/128040-php-_postvarname-does-not-work-in-any-php-page/#findComment-663177 Share on other sites More sharing options...
mikehershey Posted October 12, 2008 Author Share Posted October 12, 2008 form is in the source code above <form action="login.php" method="post"> <p>Username:<input name="username" type="text" maxlength="15"></p> <p>Password:<input name="password" type="password" maxlength="15"></p> <input type="submit"> </form> I had the script working properly on two servers, so i'm pretty sure its a configuration problem. I had the script working properly on this server but then in php.ini i raised the max file upload size and the max post variable upload size. When i did this on other servers the script continued to work. On this on the script stopped working. The two differences between this server and the other 2 are this one has mod_jk and the Suhosin-Patch installed. I think that the Suhosin-Patch might be blocking the post variables. Is this possible? Quote Link to comment https://forums.phpfreaks.com/topic/128040-php-_postvarname-does-not-work-in-any-php-page/#findComment-663184 Share on other sites More sharing options...
mikehershey Posted October 12, 2008 Author Share Posted October 12, 2008 Ok i think it was the patch i changed php.ini back down to a lower value and everything started working (except for large file transfer which is why i changed it to begin with) it worked on the other server so i'm concluding that it must be the stupid Suhosin-Patch. Thanks for replying everyone. If have any idea how to edit the Suhosin-Patch so i can upload large files that would be awesome. Quote Link to comment https://forums.phpfreaks.com/topic/128040-php-_postvarname-does-not-work-in-any-php-page/#findComment-663192 Share on other sites More sharing options...
kenrbnsn Posted October 12, 2008 Share Posted October 12, 2008 Why didn't you mention your configuration in the first post? You can look for solutions in the Suhosin-Patch support forum Ken Quote Link to comment https://forums.phpfreaks.com/topic/128040-php-_postvarname-does-not-work-in-any-php-page/#findComment-663294 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.