header issues

Hey guys - I get this error from time to time and somewhere I usualy fix it (without knowing)

but this one will not budge.

[php]<?php

						$user = $_POST['username'];
						$pass = $_POST['password'];
						
						mysql_connect("localhost", "+++++", "+++++++");
mysql_select_db("++++");
													
						if ($_SERVER['REQUEST_METHOD'] ==
						'POST') 
						
						{
						if ((empty($user)) || (empty($pass))) { 
						
						print 'Please fill out your username and password to log in<br />'; 
						
						}
						
					$result = mysql_query("SELECT * FROM users WHERE username='" . $user . "' AND password='" . $pass . "'");
						
						$number = mysql_num_rows($result);
						
						if($number==0) {print "Your login details are not correct, please try again"; } 
						
						else { header ("Location: http://www.justoliver.co.uk/eands/html5/home.php"); }

}

						mysql_close();
						
						
						
						
						
						
						
						?>[/php]

with the error

Warning: Cannot modify header information - headers already sent by (output started 

any hints? im sure its obvious…

Hello bushkid85, this type of warning is generally occurs in php due to echo or print statement is used just before the header() function is used. or may be there is a space is occurs at the beginning of script you are using.

Also code posted by you is not proper structured.
see blow code i have modify for you
[php]

<?php $user = $_POST['username']; $pass = $_POST['password']; mysql_connect("localhost", "+++++", "+++++++"); mysql_select_db("++++"); if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ((empty($user)) || (empty($pass))) { print 'Please fill out your username and password to log in
'; } else { $result = mysql_query("SELECT * FROM users WHERE username='" . $user . "' AND password='" . $pass . "'"); $number = mysql_num_rows($result); if($number==0) { print "Your login details are not correct, please try again"; } else { header ("Location: http://www.justoliver.co.uk/eands/html5/home.php"); } } } mysql_close(); ?>

[/php]

I hope this will helpful for you.
Reply your Feedback
SR

I looked at the structure of the code and fitted it with what you entered.

Still get the same error.

I cant see how I can take away the print before the header - - -

any other ideas?

I ran the php script without the HTML and it works

i cannot see how I can ammend this - re-written 5 times now.

I need onscreen validation with my login script without javascript! then to actually open the index page of the site, why is this so hard with pointless shitty errors.

SORTED !

Hello bushkid85, It's really nice to see that finally your issue is sorted. Post your other issues here you will get solution surely. :) ~~SR~~
Sponsor our Newsletter | Privacy Policy | Terms of Service