Jump to content

help urgent


azeem123456

Recommended Posts

i m having problem in redirecting  im making content management system

i get a values from posted form and then insert as an new row value is  inserted correctly but i want to redirect it back to my content.php when i use header("Location: content.php");

it gives me this error when i fill form and hit submit error is "Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\widget_corp\includes\connection.php:1) in C:\xampp\htdocs\widget_corp\create_subject.php on line 14"

and my code is <?php

$menu_name= $_POST['menu_name'];

$position = $_POST['position'];

$visible = $_POST['visible'];

 

$query = "INSERT INTO subjects (

menu_name, position, visible)

Values ( '{$menu_name}',{$position},{$visible})";

if(mysql_query($query,$connection)){

header("Location: content.php");

exit;

}else {

echo "<p> Subject creation is failed .</p>";

echo "<p>".mysql_error()."</p>";

}

plz plz help me out

Link to comment
https://forums.phpfreaks.com/topic/192688-help-urgent/
Share on other sites

Not sure if this will work, but usually if any html is called before the redirect it won't work. Do these two things..

 

First, make sure there is no space after the closing ?> tag, that includes lines..

 

Second, try putting ob_start(); at the beginning of the page. So it looks like this.

 

<?php ob_start();

code here

?>

Link to comment
https://forums.phpfreaks.com/topic/192688-help-urgent/#findComment-1015097
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.