Redirect on post submit

Hey,

I am trying to tweak a forum so that when a post is made, rather than the standard
[php]echo ‘You have succesfully created your new topic.’;[/php]

It will redirect the user to the forum category page where the topic was posted, I’ve tried

[php]header( “Location: category.php?id=’. $topic_cat . '” );[/php]
But get
Warning: Cannot modify header information - headers already sent by (output started at /home3/topictal/public_html/header.php:17)

I’ve checked in header.php and every other file on the site using dreamweave source search but returned no results :frowning:

I found an alternative

[php]echo “”;[/php]
But that is just taking me to index.php(where the topic post section is located" the data is going to the database fine, there are no errors, it’s just not redirecting to where I want it, please help :frowning:

Ok so I posted my problem in a few different places, the only solution offered that I’m not sure about is someone recommended doing a POST GET query in the same process so that the topic_id is posted to the database before the redirect happens, therefore I won’t get an empty link…

category.php?id=

When I’m trying to get either

category.php?id=1
category.php?id=2

depending on what option was selected from the drop down, hope this adds usefull additional info to my question >_<

that warning is telling you that somewhere in your code, before the header call there IS some output although not necessarily output you can see on your screen.

I’m pretty sure you have a blank space somewhere above the header call.
If you can’t find it, try output_buffering() that usually solves the problem.
(although make sure it doesn’t break something else by using it!)

Cheers,
Red. :wink:

You cant have any text output before a header call. try a meta refresh though, its worked for me in the past.

Sponsor our Newsletter | Privacy Policy | Terms of Service