Jump to content

[SOLVED] how to redirect page after include


phplearner2008

Recommended Posts

Hi,

I have a file Interest_Sent.php where there is a checkbox and delete button, When the checkbox is checked and delete is pressed, it goes to process.php.

 

I am posting the code below:

<?php
include_once('C:\Program Files\Apache Group\Apache2\htdocs\matrimonial\config.php');
$MY_ID = $_POST['MY_ID'];
if(isset($_SERVER['HTTP_REFERER'])) $ref = $_SERVER['HTTP_REFERER'];
if($ref == 'http://localhost/matrimonial/templates/Interests_Sent.php')
{
$checkbox = array();
$checkbox = $_POST['box'];
$count = count($checkbox);
for($i=0;$i<$count;$i++)
{
   $value = $checkbox[$i];
$sql = "UPDATE interests_sent SET DELETED = 'Yes', DELETED_DATE = CURDATE() WHERE MY_ID = '$MY_ID' AND INTEREST_SENT = '$value' AND DELETED = 'No'";
$result = mysql_query($sql);
if($result)
{
  ob_start();  //start buffer
include('C:\Program Files\Apache Group\Apache2\htdocs\matrimonial\Interests_Sent.php');
//we pass the output of include file to a variable
$buffer = ob_get_contents();
ob_end_clean();
header("Location:http://localhost/matrimonial/templates/Interests_Sent.php");
}  else echo "Could not delete"; 
} 

} ?>

The above code works fine except for last but one line(header line). How do I redirect my page to Interests_Sent.php after these operations at process.php is completed?

 

In other words how can I redirect a page after using include without getting "Headers already sent" error?

 

Thanks.

 

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.