I have a project developed in PHP in the Windows platform and it is running well.
I am now trying to run it on LINUX (Red Hat and CentOS). It isnot going beyond the index page.
I have zeroed in on line where where it is getting stuck.
It is the header statement. The database conncectivity is alright.
Please help if possible.
The index.php file is repoduced below.Inline Code Example Here

<html>
<head>
<?php
error_reporting(E_ALL^E_NOTICE);
include('includes/saha.css');
if (isset($_COOKIE['verify']))
{
    setcookie('verify','',time()-3600);
    unset($_COOKIE['verify']);
    unset($_COOKIE['PHPSESSID']);
}
$bgcolor=array("#FFFFCC","#99FF99","#FFCCCC","#C1C1FF","#FFA4D1","#FAD996","#F3C2F8","#D5D9A4","#E9B3FD","#FED8B1");
$R=random(1);
?>

<title>THE PRINCIPAL CONTROLLER OF DEFENCE ACCOUNTS (PENSION), ALLAHABAD.</title>
    <link rel="shortcut icon" href="images/india.gif" />
<script language="javaScript" type="text/javascript" src="js/jsindex.js"></script>
    <meta name="description" content="CEA">
    <meta name="keywords" content="CEA">
    <meta name="robots" content="index,follow">  
</head>
<body bgcolor="<?php echo $bgcolor[$R]; ?>" oncontextmenu="return false;">


<table width="100%"  border="1" cellspacing="0" cellpadding="0">
    <tr><td width="10%" align="left" bgcolor="#FFFFFF"><img src="images/India.gif" width="186" height="125"/></td>
     <td width="82%" align="center" bgcolor="#DDAE7B"><span class="style10" style='font-size:80.0pt;line-height:100%;font-family:"Kruti Dev 016"'><font color="#0000FF"><strong>isa'ku Lohd`fr</strong></font></span></td>
    <td width="13%" align="center" bgcolor="#FFFFFF"><div align="right"><img src="images/headerlogo2.jpg" width="120" height="125" /></div></td>
    </tr></table>
<table border="1" align="left" width="15%" bgcolor="#CCFF99" bordercolordark="#0033FF">
    <tr><td><div align="left"><a href="javascript:void(0);"
NAME="My Window Name" title=" View PPO" onClick=window.open("AdminMisc/viewPpo.php","Ratting","width=750,height=300,0,status=0,scrollbars=1");>View PPO</a></div></td></tr>
    <tr><td><div align="left"><a href="javascript:q=(document.location.href); void(open('CDR/CDRSearchHelp/claimReporting.php?url='+escape(q),'','directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=no,width=1300,height=800'));"><blink><font color="#660000" size="4"><strong>Claim Reporting</strong></font></blink></a></div></td></tr>
    <tr><td><div align="left"><a href="javascript:void(0);"
NAME="My Window Name" title=" Claim Diary Report " onClick=window.open("CDR/CDRSearchHelp/claimsearch.php","Ratting","width=750,height=300,0,status=0,scrollbars=1");>View Claims</a></div></td></tr>
    <tr><td><div align="left"><a href="Firefox Setup 15.0.1.exe">Load Firefox Mozilla Browser</a></div></td></tr>
</table>
<form method="post">
<center>
<fieldset style="max-width:50%" ><legend>

<p>
<span class="style10">Pension Sanction : Login Screen</span></p>
</legend>
<table align="center" width="40%"><tr height="50px"><td></td></tr>
<tr><td>ID</td><td><input type="text" name="id" maxlength="7" id="id" /></td></tr>
<tr><td>Password</td><td><input type="password" name="password" maxlength="15" id="password" /></td></tr>
<tr><td>Designation</td><td><select name="designation" id="designation"><option selected="selected">select</option><option>AUDITOR</option><option>AAO</option><option>AO</option><option>ADMINISTRATOR</option></select></td></tr>
<tr><td></td><td align="center"><input type="submit" name="submit_myform" value="Submit" class="button" /></td></tr>
<tr><td align="right" colspan="2"><a href="javascript: alert('Please Contact your local Admin of EDP Centre.');"/>Forgot Password</a></td></tr>
</table></fieldset>
</center>
</form>

<p>

 <?php 
if(session_start()){    session_destroy();}

include ('classes/psql.php');
include ('classes/admin.php');
$psql1=new psql();
$admincheck=new admin();

$psql1->dbConSargam();
$admincheck->PostfixofDate();


if(isset($_POST['submit_myform']))
{
    session_start();

    $login=$_POST;
    $desig=trim($_POST['designation']);
    $id= mysql_real_escape_string(trim($_POST['id']));
    $pass= mysql_real_escape_string(trim($_POST['password']));
    //$_SESSION['logt']="Welcome ".$id."<a href='../logout.php'>Logout</a>";


    $result=mysql_query("select * from login where id='".$id."' and password='".$pass."' and designation='".$desig."' and isactive='y'");
    $oneresult=mysql_fetch_array($result);
    $psql1->dbConSargam_record();
    $validate=$admincheck->LoginValidation($login,$oneresult);

    if($oneresult[0]!='' && $oneresult[0]!="" && $oneresult[0]!='0' && $validate=="Y")
    {
        $_SESSION['currid']=$oneresult['id'];
        $_SESSION['name']=$oneresult['name'];
        $_SESSION['desig']=$oneresult['designation'];
        $_SESSION['grpCode']=$oneresult['grpCode'];
        $_SESSION['section']=$oneresult['section'];
        $_SESSION['password']=$oneresult['password'];
        $confirmuser=$id.$pass.$desig;
        $confirmuser=md5($confirmuser);
setcookie('verify',$confirmuser,time()+60*45);
unset($confirmuser);
        if($oneresult['section']=='PB' || $oneresult['section']=='PD' || $oneresult['section']=='PF'){header("location: AdminMisc/home.html");}
        elseif($oneresult['section']=='CS' || $oneresult['section']=='CF'){header("location: AdminMisc/homeCiv.html");}
        elseif($oneresult['section']=='OS' || $oneresult['section']=='OD'|| $oneresult['section']=='OF'){***header("location: AdminMisc/homeOff.html");***}
        elseif($oneresult['section']=='SA'){header("location: AdminMisc/superAdmin/confirSuperadmin.php"); $_SESSION['count']=1;}
    }
    else
    {
    echo"<br><center><font color='red'>Incorrect input! Try again.</font></center>";
    }

}

function random($length) 
{ 
$random= "";
srand((double)microtime()*1000000);

$data = "0123456789"; 
for($i = 0; $i < $length; $i++) 
{ 
$random .= substr($data, (rand()%(strlen($data))), 1); 
}

return $random;
}
?>
</body>

what is that 3 times asterisk sign around header function on line 100?
***

@urtrivedi
Thanks for looking into my problem.
This triple asterisk has been added by the dani editor as I wanted to boldface that code segment for highlighting. It is not part of code. Please remove it.
Regarding the problem, that is the line (containing the header statement) of code where the program is getting stuck.
Regards.

You can't use a header redirect if you have already outputted HTML.

You should get used to using constants that are defined by PHP for things like directory separators which should make your code more portable. If anywhere in your code you have used anything that is Windows specific i.e. directory separators, running it on linux will fail. In this case use DIRECTORY_SEPARATOR which is defined by PHP and will ensure it will be correct on either Windows or Linux.

As pritaeas mentioned above, you cannot do a header redirect (Like on lines 99 & 101) when you have already outputted HTML. A trick to get around this is to use output buffering, though this isn't the best solution.

@pritaeas @bops
Thanks a lot. The trick worked. When separated the HTML template codes from the php code containing the header statements, the thing worked. I put line 57 and beyond into another file and set the form action attribute to the new page. It worked.
Thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.