Jump to content

Problem with header function.


lional

Recommended Posts

Hi All

I am having a problem with my header function. The error message is:

Warning: Cannot modify header information - headers already sent by (output started at D:\htdocs\returns\ra\top_verify.php:7) in D:\htdocs\returns\ra\ra_verify_logon.php on line 31

Here is the code for the two pages:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>Returns Application</title>

<meta name="description" content="masons">

<meta name="keywords" content="masons">

<script>

//"Accept terms" form submission- By Dynamic Drive

//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com

//This credit MUST stay intact for use

var checkobj

function agreesubmit(el){

checkobj=el

if (document.all||document.getElementById){

for (i=0;i<checkobj.form.length;i++){  //hunt down submit button

var tempobj=checkobj.form.elements

if(tempobj.type.toLowerCase()=="submit")

tempobj.disabled=!checkobj.checked

}

}

}

function defaultagree(el){

if (!document.all&&!document.getElementById){

if (window.checkobj&&checkobj.checked)

return true

else{

alert("Please Click Accept")

return false

}

}

}

</script>

<script type='text/javascript'>

//HV Menu- by Ger Versluis (http://www.burmees.nl/)

//Submitted to Dynamic Drive (http://www.dynamicdrive.com)

//Visit http://www.dynamicdrive.com for this script and more

function Go(){return}

</script>

<link rel=alternate media=print href="print_verify_data.php">

<link href="../css/browserButton.css" rel="stylesheet" type="text/css" media="all" />

</head>

<body background="../images/bg.jpg" topmargin="3" leftmargin="0">

<table summary="" align="center" width="750" cellspacing="0" cellpadding="0">

<tr>

<td>

<table summary="" width="750" cellspacing="0" cellpadding="0">

<tr>

<td width="270" height="130" align="center" valign="top">

<img src="../images/distr_badge_transp.gif" alt="">

</td>

</tr>

</table>

</table>

</table>

 

and

 

<?php

include '../includes/conn_db.php';

include'../ra/top_verify.php';

if (isset($_POST["submit"])) {

$user = $_POST["user"];

$pass = $_POST["pass"];

$chapt = $_POST["chapter"];

$dist = $_POST["district"];

$auth=false;

$query = "SELECT * from ra_login WHERE chapter_no = '$chapt' AND district_no = '$dist'";

$result = mysql_query($query, $conn);

while ($row = mysql_fetch_assoc($result)){

if ($user == $row["username"] && $pass == $row["password"]) {

$auth = true;

break;

}

}

if ($auth) {

$_SESSION["username"] = $user;

$url = "http://localhost/returns/ra/ra_verify_details.php?district=$dist&chapter=$chapt";

} else {

$url = "royal_arch_logon_failure.php";

}

if (!isset($_COOKIE[session_name()])) {

if (strstr($url, "?")) {

header("Location: " . $url . "&" . session_name() . "=" . session_id());

} else {

header("Location: ". $url . "?" . session_name() . "=" . session_id());

}

} else {

header("Location: " . $url);

}

}

 

?>

 

Can anyone please tell me what is wrong with this, I have been staring at it for hours and it eludes me.

 

Thanks

 

Lional

Link to comment
https://forums.phpfreaks.com/topic/36741-problem-with-header-function/
Share on other sites

Stuff

Put ob_start(); at the very beginning of the file before any non-php code is ran and before any kind of echo or print is used, and after all possible uses of header put ob_end_flush();

 

This ensures that headers are never used after data has been sent to the client and fixes the problem.

Archived

This topic is now archived and is 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.