MadDawgX Posted November 12, 2006 Share Posted November 12, 2006 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 REplyif(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. Quote Link to comment Share on other sites More sharing options...
toplay Posted November 12, 2006 Share Posted November 12, 2006 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. Quote Link to comment Share on other sites More sharing options...
printf Posted November 12, 2006 Share Posted November 12, 2006 Other than no exit(); after the location header I don't see anything wrong. [b]user[/b] is not reserved word, the only reserved word that contains user is, [b]current_user[/b]! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.