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
https://forums.phpfreaks.com/topic/26982-header-error/
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
https://forums.phpfreaks.com/topic/26982-header-error/#findComment-123373
Share on other sites

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.