I'm new to php and have been trying to teach myself for the last few months. I had a site completely finished through a test url and everything including php pages that talked to my mysql database worked perfectly. Yesterday I put the site on it's intended url and now my back end admin pages are not working. I imported the original database and changed all the needed names for my connection page. What appears to be the problem is that session_start is conflicting with header commands. These are the errors that I get.
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/64/7074664/html/pages/logver.php:1) in /home/content/64/7074664/html/pages/logver.php on line 28
Warning: Cannot modify header information - headers already sent by (output started at /home/content/64/7074664/html/pages/logver.php:1) in /home/content/64/7074664/html/pages/logver.php on line 30
and this is my code for logver.php:
echo "<div class='thanks'>";
$user = $_POST['myusername'];
$pass = $_POST['mypassword'];
mysql_connect($hostname, $username,$password )or die("can't connect");
mysql_select_db($dbname) or die("Couldn't find DB");
$sql = "SELECT * FROM users WHERE `username`='".$user."'";
$result = mysql_query($sql);
$numrows = mysql_num_rows($result);
while($row = mysql_fetch_assoc($result))
$dbuser = $row['username'];
$dbpass = $row['password'];
header ("Location: admin_page.php");
echo "That password is incorrect";
die ("That user doesn't exist");
die ("Please enter username and password");
I do have a small css style that proceeds this, but when I tried to take it out it actually led to more confusion (which I may have to fix on another page later), so it's left in for now.
As I understand my session_start may need to be at the top of the page? I've tried this but it hasn't helped me any. Besides I don't see how I can start the session before I've entered the username and password?
Why might this work perfectly on my test site and not on the actual site?
Any help here would be much appreciated.