SilverNova Posted August 1, 2006 Author Share Posted August 1, 2006 http://lov3d.com/test.htmThey all show.. :\ I thought test 2 didnt but realised you went 1,3,4.. :PSee your sig - I had a brief look around :) Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67141 Share on other sites More sharing options...
Ninjakreborn Posted August 1, 2006 Share Posted August 1, 2006 test1test3test4test5Warning: Cannot modify header information - headers already sent by (output started at /home/lov3dco/public_html/test.php:3) in /home/lov3dco/public_html/test.php on line 24 Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67143 Share on other sites More sharing options...
Ninjakreborn Posted August 1, 2006 Share Posted August 1, 2006 As I said earlier there "something" above session_start();also if all the tests are showing something isn't working right.make sure <?phpsession_start();?>the <?php make sure it's at the top wall of the page, with nothing else above it.not html, or anything. Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67144 Share on other sites More sharing options...
SilverNova Posted August 1, 2006 Author Share Posted August 1, 2006 yeah it is encoded with md5 in the tablethe password field for the row is 098f6bcd4621d373cade4e832627b4f6.. which = "test"there are other fields which just have blank entries so this shouldn't matter? like "email" for their email address etc. Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67145 Share on other sites More sharing options...
wildteen88 Posted August 1, 2006 Share Posted August 1, 2006 Something is being outputted on line 3 in test.php. As this where PHP has detected where the output has started:[quote]Warning: Cannot modify header information - headers already sent by ([color=red][b]output started at /home/lov3dco/public_html/test.php:3[/b][/color]) in /home/lov3dco/public_html/test.php on line 24[/quote]Note the bit in bold above. Thats the important bit you want to read. Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67146 Share on other sites More sharing options...
Ninjakreborn Posted August 1, 2006 Share Posted August 1, 2006 what about something in php.ini or htaccess that is making something output before the php page is even called from the server, that could be causing it.??? Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67149 Share on other sites More sharing options...
SilverNova Posted August 1, 2006 Author Share Posted August 1, 2006 [img]http://www.lov3d.com/test.png[/img]That's what I have.Also, why can't i see this warning message?!!!? I'm using FF, all I get after login is: "test1test3test4test6" on the test.php page :\ ??? Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67150 Share on other sites More sharing options...
Ninjakreborn Posted August 1, 2006 Share Posted August 1, 2006 browsers handling sessions differently I never heard of it, it has something to do with php.ini I would guess, for now give us your entire php.ini file, and anything you might have in your .htaccess page. Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67153 Share on other sites More sharing options...
SilverNova Posted August 1, 2006 Author Share Posted August 1, 2006 I've never had to use php.ini before, all I know is that it's a global set of events etcYou're welcome to have a look - http://lov3d.com/php.iniI presume it's in the right place, I took it from php.net after being told I should use (well, open) it. I don't seem to have a php.ini file elsewhere on my server unless i'm not looking in the right places.It's not the .htaccess :\ - it's blank at the moment Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67155 Share on other sites More sharing options...
Ninjakreborn Posted August 1, 2006 Share Posted August 1, 2006 maybe sometimes you can't have anything next to session_start();good practice, try putting it in it's own section<?phpsession_start();?><?phpeverything else hereTry that, but I don't understand this, the reason itw as coming up blank is the username and password don't match, or one of the queries is wrong, I don't see what else can be causing this. Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67156 Share on other sites More sharing options...
Ninjakreborn Posted August 1, 2006 Share Posted August 1, 2006 [code]session.cookie_lifetime = 0[/code]increase that to 4 hours will allow the cookie to work after the browser is shut down. There is nothing wrong with php.ini what about .htaccessTHe thing I would suggest is give me a little while if no one else can help.I am leaving for like 2 hours. Be back later. Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67158 Share on other sites More sharing options...
wildteen88 Posted August 1, 2006 Share Posted August 1, 2006 The error isnt to do with the session anymore. But to do with the header redirect on line 24. From looking at the sreenie, you have output on line 3 - echo "testl"; Remove that otherwise the header function wont work (on line 24). Pleae read the error message correctly and that you understand it. Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67159 Share on other sites More sharing options...
SilverNova Posted August 1, 2006 Author Share Posted August 1, 2006 I changed it to:[code]<?phpsession_start();?><?phpecho "test1";$username = $_POST["username"]; //get the username from the form, as $username$password = md5($_POST["password"]); //get the password from the form in md5[/code]..etc.Still nothing.. Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67160 Share on other sites More sharing options...
Ninjakreborn Posted August 1, 2006 Share Posted August 1, 2006 try what wildteen said for now, remove test1, the echo at the top, see if that fixes that part, then we can concentrate on the part below that to get the query to work. Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67161 Share on other sites More sharing options...
Ninjakreborn Posted August 1, 2006 Share Posted August 1, 2006 he was right, the error is changing based on teh location, I don't know the technicalities of how far it has to be, but I guess don't use echo's too close to the thing, just remove test1 Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67162 Share on other sites More sharing options...
Ninjakreborn Posted August 1, 2006 Share Posted August 1, 2006 king arthur was right I was wondering what he was talking about at first. Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67163 Share on other sites More sharing options...
SilverNova Posted August 1, 2006 Author Share Posted August 1, 2006 changed php.ini[code]; Lifetime in seconds of cookie or, if 0, until browser is restarted.session.cookie_lifetime = 0[/code]to[code]; Lifetime in seconds of cookie or, if 0, until browser is restarted.session.cookie_lifetime = 2400[/code]and test.php now looks like this after taking out the echo:[code]<?phpsession_start();?><?php$username = $_POST["username"]; //get the username from the form, as $username$password = md5($_POST["password"]); //get the password from the form in md5$users = mysql_connect("localhost", "lov3dco_users", "test"); if(!$users) { echo "<p>Sorry! We could not log you in at this time. Please Try again later!</p>"; exit(); }echo "test3";mysql_select_db("lov3dco_users"); //select what database to use$username = mysql_real_escape_string($username);$password = mysql_real_escape_string($password);$recieve = "SELECT * FROM users WHERE username = '$username' AND password = '$password';";$query = mysql_query($recieve) or die("Unable to peform query - " . mysql_error()); //do the queryecho "test4";if($rows = mysql_num_rows($query)){ $_SESSION['password'] = $password; //store the users password in a sesions var $_SESSION['username'] = $username; //store the username in a session var$page = "index.php"; header('Location: ' . $page);}else {echo "test6"; session_destroy(); }?>[/code]Still blank, apart from the echo's - http://lov3d.com/test.htm Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67164 Share on other sites More sharing options...
wildteen88 Posted August 1, 2006 Share Posted August 1, 2006 You have a bunch of echos which is why your code is not working try this:[code=php:0]<?phpsession_start();$username = $_POST["username"]; //get the username from the form, as $username$password = md5($_POST["password"]); //get the password from the form in md5$users = mysql_connect("localhost", "lov3dco_users", "test"); if(!$users) { echo "<p>Sorry! We could not log you in at this time. Please Try again later!</p>"; exit(); }mysql_select_db("lov3dco_users"); //select what database to use$username = mysql_real_escape_string($username);$password = mysql_real_escape_string($password);$recieve = "SELECT * FROM users WHERE username = '$username' AND password = '$password';";$query = mysql_query($recieve) or die("Unable to peform query - " . mysql_error()); //do the queryif($rows = mysql_num_rows($query)){ $_SESSION['password'] = $password; //store the users password in a sesions var $_SESSION['username'] = $username; //store the username in a session var$page = "index.php";header('Location: ' . $page);}else { session_destroy();}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67165 Share on other sites More sharing options...
SilverNova Posted August 1, 2006 Author Share Posted August 1, 2006 Ok, test.php now looks exactly like the above and returns a blank page..Think businessman just put them in earlier to differentiate what was going on Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67168 Share on other sites More sharing options...
wildteen88 Posted August 1, 2006 Share Posted August 1, 2006 Okay so something is failing somewhere.Chnage this:[code]if($rows = mysql_num_rows($query)){ $_SESSION['password'] = $password; //store the users password in a sesions var $_SESSION['username'] = $username; //store the username in a session var$page = "index.php";header('Location: ' . $page);}else { session_destroy();}[/code]to this:[code]if($rows = mysql_num_rows($query)){ echo "login successful";}else { echo "login failed";}[/code]Do you get anythink now? Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67169 Share on other sites More sharing options...
SilverNova Posted August 1, 2006 Author Share Posted August 1, 2006 Yeah, "login failed"Here's my table just in case..[img]http://www.lov3d.com/testdb.png[/img] Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67171 Share on other sites More sharing options...
wildteen88 Posted August 1, 2006 Share Posted August 1, 2006 Change[code=php:0]if($rows = mysql_num_rows($query)){[/code]to[code=php:0]if(mysql_num_rows($query) == '1'){[/code]What does that produce? Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67172 Share on other sites More sharing options...
SilverNova Posted August 1, 2006 Author Share Posted August 1, 2006 try again - i got parse error = the echo, login successfulI know you mean "if" obviously.. :P Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67173 Share on other sites More sharing options...
wildteen88 Posted August 1, 2006 Share Posted August 1, 2006 I had a typo before, it should of been this:[code]if(mysql_num_rows($query) == '1'){[/code]Are you getting login successfull now?If you are you can replace:[code]if(mysql_num_rows($query) == '1'){ echo "login successful";}else { echo "login failed";}[/code]with:[code]if(mysql_num_rows($query) == '1'){ $_SESSION['password'] = $password; //store the users password in a sesions var $_SESSION['username'] = $username; //store the username in a session var header('Location: index.php');}else{ session_destroy(); echo "login failed, please try again";}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67177 Share on other sites More sharing options...
SilverNova Posted August 1, 2006 Author Share Posted August 1, 2006 Nope. sorry :-\[code]<?phpsession_start();$username = $_POST["username"]; //get the username from the form, as $username$password = md5($_POST["password"]); //get the password from the form in md5$users = mysql_connect("localhost", "lov3dco_users", "test"); if(!$users) { echo "<p>Sorry! We could not log you in at this time. Please Try again later!</p>"; exit(); }mysql_select_db("lov3dco_users"); //select what database to use$username = mysql_real_escape_string($username);$password = mysql_real_escape_string($password);$recieve = "SELECT * FROM users WHERE username = '$username' AND password = '$password';";$query = mysql_query($recieve) or die("Unable to peform query - " . mysql_error()); //do the queryif(mysql_num_rows($query) == '1'){ echo "login successful";}else { echo "login failed";}?>[/code]gives login failed Quote Link to comment https://forums.phpfreaks.com/topic/16207-why-doesnt-this-work/page/2/#findComment-67182 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.