Jump to content

Need help with a Warning Modify header.


co.ador

Recommended Posts

Warning: Cannot modify header information - headers already sent by (output started at /home3/nyhungry/public_html/storeprueba/storescripts/connect_to_mysql.php:2) in /home3/nyhungry/public_html/storeprueba/storeadmin/admin_login.php on line 29

 

What can I do to fix the error where a second header is called, needed but intervening

 

admin_login.php

 

<?php 

session_start();
    if (isset($_SESSION["manager"])) 
{
    header("location:index.php"); 
    exit();
}
?>
<?php 

if (isset($_POST["username"]) && isset($_POST["password"])) 
{
$manager = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["username"]); // filter everything but numbers and letters
       $password = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["password"]); // filter everything but numbers and letters
  
           include "../storescripts/connect_to_mysql.php"; 
           $sql = mysql_query(
                            "SELECT id 
                              FROM admin 
                              WHERE username='$manager' 
                              AND password='$password' 
                              LIMIT 1"); 

    $existCount = mysql_num_rows($sql); 
       if ($existCount == 1) 
     { 
     while($row = mysql_fetch_array($sql))
            { 
             $id = $row["id"];
             }
	 $_SESSION["id"] = $id;
	 $_SESSION["manager"] = $manager;
	 $_SESSION["password"] = $password;
	 header("location:index.php");
         exit();
    } else 
      {
	echo 'That information is incorrect, try again <a href="index.php">Click Here</a>';
	exit();
}
}
?>

 

is the  second header here like below in the code clashing? because in the connect_to_mysql.php there is no headers

 

	
<?php
                $_SESSION["id"] = $id;
	 $_SESSION["manager"] = $manager;
	 $_SESSION["password"] = $password;
	 header("location:index.php");
                    exit();
<?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.