hi every body
I have written a code for deletion of records from database.
my navigation path is like this
1. member.php (for selecting the delete option from menu)
2. deleteadministrator.php ( for entering id of customer and search for the record if reord found then to click on delete button)
3. deleteadministratorexe.php ( after clicking on button in deleteadministrator.php it executes the deletion sql code written in deleteadministratorexe.php)

Till this point every thing is fine but when I am trying to redirect the page after deleting the record from deleteadministratorexe.php to member.php I am getting an ERROR -
"Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\pamanet\deleteadministratorexe.php:12) in C:\wamp\www\pamanet\deleteadministratorexe.php on line 29"

Here is my deleteadministratorexe.php code-

<?php
require_once('security.php');

$str = $_GET['id'];
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Member Index</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style5 {
	color: #CC0000;
	font-weight: bold;
}
-->
</style>
</head>
<body>
<h1>Welcome <font color="#FF6600"><?php echo $_SESSION['loginname'];?></font></h1>| <a href="logout.php">Logout</a>
<p>This is a password protected area only accessible to members. </p>
<?php
include('show.php');
require_once('connection.php');
$qry = "delete from `users_table` where cust_id='$str'";
$result = mysql_query($qry); 
header('Location: http://localhost/pamanet/member.php');
?>
<p>&nbsp;</p>
</body>
</html>

Please help me in solving this error.

Thanx in advance

hi every body
I have written a code for deletion of records from database.
my navigation path is like this
1. member.php (for selecting the delete option from menu)
2. deleteadministrator.php ( for entering id of customer and search for the record if reord found then to click on delete button)
3. deleteadministratorexe.php ( after clicking on button in deleteadministrator.php it executes the deletion sql code written in deleteadministratorexe.php)

Till this point every thing is fine but when I am trying to redirect the page after deleting the record from deleteadministratorexe.php to member.php I am getting an ERROR -
"Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\pamanet\deleteadministratorexe.php:12) in C:\wamp\www\pamanet\deleteadministratorexe.php on line 29"

Here is my deleteadministratorexe.php code-

<?php
require_once('security.php');

$str = $_GET['id'];
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Member Index</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style5 {
	color: #CC0000;
	font-weight: bold;
}
-->
</style>
</head>
<body>
<h1>Welcome <font color="#FF6600"><?php echo $_SESSION['loginname'];?></font></h1>| <a href="logout.php">Logout</a>
<p>This is a password protected area only accessible to members. </p>
<?php
include('show.php');
require_once('connection.php');
$qry = "delete from `users_table` where cust_id='$str'";
$result = mysql_query($qry); 
header('Location: http://localhost/pamanet/member.php');
?>
<p>&nbsp;</p>
</body>
</html>

Please help me in solving this error.

Thanx in advance

header("Location: member.php");

. try it once. this error occures if you have any 'echo' before it. all the files are in same folder no need give full path.

header('Location: http://localhost/pamanet/member.php');

put once like below. if member.php is in other folder. i don't know your correct file location .just i am expecting. if below is not work then put coorect path of file.

header('Location:pamanet/member.php');
header("Location: member.php");

. try it once. this error occures if you have any 'echo' before it. all the files are in same folder no need give full path.

Thanx for your consideration...
But still getting same ERROR... no change

put once like below. if member.php is in other folder. i don't know your correct file location .just i am expecting. if below is not work then put coorect path of file.

header('Location:pamanet/member.php');

done like you told but no change getting same ERROR
and my all files are under same folder "pamanet"...

Thanx for your consideration...
But still getting same ERROR... no change

<?php echo $_SESSION['loginname'];?>

once delete this echo see what hapnd. try it once.

hi every body
I have written a code for deletion of records from database.
my navigation path is like this
1. member.php (for selecting the delete option from menu)
2. deleteadministrator.php ( for entering id of customer and search for the record if reord found then to click on delete button)
3. deleteadministratorexe.php ( after clicking on button in deleteadministrator.php it executes the deletion sql code written in deleteadministratorexe.php)

Till this point every thing is fine but when I am trying to redirect the page after deleting the record from deleteadministratorexe.php to member.php I am getting an ERROR -
"Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\pamanet\deleteadministratorexe.php:12) in C:\wamp\www\pamanet\deleteadministratorexe.php on line 29"

Here is my deleteadministratorexe.php code-

<?php
require_once('security.php');

$str = $_GET['id'];
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Member Index</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style5 {
	color: #CC0000;
	font-weight: bold;
}
-->
</style>
</head>
<body>
<h1>Welcome <font color="#FF6600"><?php echo $_SESSION['loginname'];?></font></h1>| <a href="logout.php">Logout</a>
<p>This is a password protected area only accessible to members. </p>
<?php
include('show.php');
require_once('connection.php');
$qry = "delete from `users_table` where cust_id='$str'";
$result = mysql_query($qry); 
header('Location: http://localhost/pamanet/member.php');
?>
<p>&nbsp;</p>
</body>
</html>

Please help me in solving this error.

Thanx in advance

The error is because u are sending output to the browser before using header() function. A header must be called before sending any output to the browser(in ur case u r using html code which is supposed to be shown in browser.)
The only remedy for this is to use header function before sending any output to browser. This can be accomplished in 3 ways:
i) you can remove all the html code because i cant see any use of it(As this page is meant for execution of deletion function u have nothing to show user. Keep it as pure php script.)
ii) you can place the header function before any html code starts.(ur php code below header will still be executed dont worry about it)
iii) use ob_start() which will buffer the output and wont send anything to browser unless u flush it...
Hope this helps..
Cheers!!

The error is because u are sending output to the browser before using header() function. A header must be called before sending any output to the browser(in ur case u r using html code which is supposed to be shown in browser.)
The only remedy for this is to use header function before sending any output to browser. This can be accomplished in 3 ways:
i) you can remove all the html code because i cant see any use of it(As this page is meant for execution of deletion function u have nothing to show user. Keep it as pure php script.)
ii) you can place the header function before any html code starts.(ur php code below header will still be executed dont worry about it)
iii) use ob_start() which will buffer the output and wont send anything to browser unless u flush it...
Hope this helps..
Cheers!!

I tried after removing all the html code from page
it looks like this-

<?php
require_once('security.php'); 
$str = $_GET['id'];
include('show.php');
require_once('connection.php');
$qry = "delete from `users_table` where cust_id='$str'";
$result = mysql_query($qry); 
header('Location: http://localhost/pamanet/member.php');
?>

I tried after removing all the html code from page
it looks like this-

<?php
require_once('security.php'); 
$str = $_GET['id'];
include('show.php');
require_once('connection.php');
$qry = "delete from `users_table` where cust_id='$str'";
$result = mysql_query($qry); 
header('Location: http://localhost/pamanet/member.php');
?>

is it working fine now?

I tried after removing all the html code from page
it looks like this-

<?php
require_once('security.php'); 
$str = $_GET['id'];
include('show.php');
require_once('connection.php');
$qry = "delete from `users_table` where cust_id='$str'";
$result = mysql_query($qry); 
header('Location: http://localhost/pamanet/member.php');
?>

So what was the outcome?
and btw what is that show.php for? check if it contains any echo or any code that will send output to browser as it may lead to same error..

I tried after removing all the html code from page
it looks like this-

<?php
require_once('security.php'); 
$str = $_GET['id'];
include('show.php');
require_once('connection.php');
$qry = "delete from `users_table` where cust_id='$str'";
$result = mysql_query($qry); 
header('Location: http://localhost/pamanet/member.php');
?>
1.
      <?php
ob_start();
   2.
      require_once('security.php');
   3.
      $str = $_GET['id'];
   4.
      include('show.php');
   5.
      require_once('connection.php');
   6.
      $qry = "delete from `users_table` where cust_id='$str'";
   7.
      $result = mysql_query($qry);
   8.
      header('Location:member.php');
   9.
      ?>

is it working fine or not

is it working fine now?

done greate job done by you all

So what was the outcome?
and btw what is that show.php for? check if it contains any echo or any code that will send output to browser as it may lead to same error..

Hi Venkat
Vishal is thnkful to you
I removed show.php also and now it is working fine
But what if I want to show deletion successed message to user

Hi Venkat
Vishal is thnkful to you
I removed show.php also and now it is working fine
But what if I want to show deletion successed message to user

Glad i could help...
Well there are other methods to do so...
Redirect ur user to "delete_successful" page rather than sending him to member.php
or
the best practice i can suggest is:
call this as a function deleteuser($uid) which will return true on success and then depending to return value you can display a javascript popup or just a simple notification msg in the page itself...

Glad i could help...
Well there are other methods to do so...
Redirect ur user to "delete_successful" page rather than sending him to member.php
or
the best practice i can suggest is:
call this as a function deleteuser($uid) which will return true on success and then depending to return value you can display a javascript popup or just a simple notification msg in the page itself...

Venkat I understood
and lots of way to do what you said.. But I can't
Can you please give me some code and tell me where to put them in my code

Venkat I understood
and lots of way to do what you said.. But I can't
Can you please give me some code and tell me where to put them in my code

Ok for now, ie to get things working, simply change the header location to delete_successful.php
create a page delete_successful.php which will echo a message that "Deleted Successfully" and will have a link to members.php which will say "go back to members page"..
should get u going for now...
Cheers!!

Ok for now, ie to get things working, simply change the header location to delete_successful.php
create a page delete_successful.php which will echo a message that "Deleted Successfully" and will have a link to members.php which will say "go back to members page"..
should get u going for now...
Cheers!!

Yes this way I tested and it is working... But the next way you told that one actually looks better

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.