Jump to content


Photo

Header error.. redirect


  • Please log in to reply
5 replies to this topic

#1 jwwceo

jwwceo
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts

Posted 26 October 2006 - 04:33 PM

Hello,

I have a function to delete a record from a databse. Once it's done I need to redorect to the main index page of my admin system, because the deleted record is no longer there to look at.

I'm using this:

header("Location: /index.php");

The delete works but I get his error:

Warning: Cannot modify header information - headers already sent by (output started at /home/jwwceo/www.vectortees.com/admin/inc/header.php:24) in /home/jwwceo/www.vectortees.com/admin/orderpage.php on line 47

I've read about not having any html output before the header command, but I'm not exactly sure what this means. I've used this command a ton of time sbefore and it always works.

any tips?  Thanks in advance.

#2 EKINdesigns

EKINdesigns
  • Members
  • PipPipPip
  • Advanced Member
  • 53 posts
  • LocationUSA

Posted 26 October 2006 - 04:36 PM

put this at the top of your page:

ob_start();


#3 php_joe

php_joe
  • Members
  • PipPipPip
  • Advanced Member
  • 175 posts

Posted 26 October 2006 - 04:37 PM

You have to put the header("Location: /index.php"); before there's any actual text generated. It's best to put it before everything else.

Joe
[url=http://darkswordsguide.com][/url]

#4 jwwceo

jwwceo
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts

Posted 26 October 2006 - 04:45 PM

I don' think there is any text generated before this.... here is my code...for the top part of that page...

<?php


include 'inc/header.php';

if (isset($_POST['deletetext'])) {

$deletetext =($_POST['deletetext']);

if ($deletetext == 'yes'){


$updatestatus = "DELETE FROM orders WHERE ordernum ='$ordernum'";
mysql_query($updatestatus) or die("Error: ". mysql_error(). " with query ". $updatestatus);

header("Location: /index.php");}



#5 php_joe

php_joe
  • Members
  • PipPipPip
  • Advanced Member
  • 175 posts

Posted 26 October 2006 - 04:54 PM

What's in header.php?

Joe
[url=http://darkswordsguide.com][/url]

#6 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 26 October 2006 - 06:13 PM

There is output in header.php around line 24

Post lines 20 - 28 here from header.php

I guess header.php outputs HTML which shows your header graphic and stuff. This is the culprit.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users