Jump to content

header error


MadDawgX

Recommended Posts

Hey there. I'm stuck on how to get my page to redirect after posting a form. I'm using an include system for my layout and in one of the includes that goes into the body I have the following:

[code]<?php
// NEW REPLY

// Connect to Database
********

// Get Current Forum/User
$current_topic = $_GET['t'];
$current_user = $_SESSION['username'];

// Add New REply
if(isset($_POST['post'])) {
$pos_post = $_POST['post'];
if ($pos_post != '') {
$q_newpost = "INSERT INTO bd_posts (topic,user,content) VALUES('$current_topic','$current_user','$pos_post')";
$r_newpost = mysql_query($q_newpost) or die('Error, query failed');
header("Location:index.php?id=1&page=2&showtopic=$current_topic");
}
}
?>

HTML STUFF[/code]

I'm getting the common [b]Warning: Cannot modify header information - headers already sent[/b] error. Help appreciated.
Link to comment
Share on other sites

1) You can't send any output to the browser before using the header(). Read the pinned topic regarding this.

2) You need a space after the colon in "Location: ".

3) You need an exit after the header().

4) I believe "user" is a reserved word in MySQL. So, enclose that column name in backtick marks like `user`

Good luck.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.