Skip to main content
deleted 406 characters in body; edited tags; edited title
Source Link
Dharman
  • 33.9k
  • 27
  • 106
  • 157

PHP Header location redirect is not working

include( 'header.php'); $name = $_POST['name']; $score = $_POST['score']; $dept = $_POST['dept']; $MyDB->prep("INSERT INTO demo (`id`,`name`,`score`,`dept`, `date`) VALUES ('','$name','$score','$dept','$date')"); // Bind a value to our :id hook // Produces: SELECT * FROM demo_table WHERE id = '23'php'; $MyDB->bind(':date', $date); // Run... thesome query $MyDB->run();code header('Location:index.php');  exit; 

The above code keeps giving me an issue with the redirect. The error is the following:

Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/testygubbins/OO/test/header.php:15) in /Applications/MAMP/htdocs/testygubbins/OO/test/form.php on line 16.

I am totally flummoxed by this. Does anyone know what IWhat should I be doing to make it work?

EDIT

header.php code:

<?php include( 'class.user.php');php'; include( 'class.Connection.php');php'; $date = date('Y-m-j'); ?> <html> <head> <link rel=StyleSheet href="css/style.css" type="text/css" media=screen> <title>Test</title> </head> <body> <div id="page"> 

PHP Header redirect not working

include('header.php'); $name = $_POST['name']; $score = $_POST['score']; $dept = $_POST['dept']; $MyDB->prep("INSERT INTO demo (`id`,`name`,`score`,`dept`, `date`) VALUES ('','$name','$score','$dept','$date')"); // Bind a value to our :id hook // Produces: SELECT * FROM demo_table WHERE id = '23' $MyDB->bind(':date', $date); // Run the query $MyDB->run(); header('Location:index.php');  exit; 

The above code keeps giving me an issue with the redirect. The error is the following:

Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/testygubbins/OO/test/header.php:15) in /Applications/MAMP/htdocs/testygubbins/OO/test/form.php on line 16.

I am totally flummoxed by this. Does anyone know what I should be doing to make it work?

EDIT

header.php code:

<?php include('class.user.php'); include('class.Connection.php'); $date = date('Y-m-j'); ?> <html> <head> <link rel=StyleSheet href="css/style.css" type="text/css" media=screen> <title>Test</title> </head> <body> <div id="page"> 

PHP Header location redirect is not working

include 'header.php'; // ... some code header('Location:index.php'); exit; 

The above code keeps giving me an issue with the redirect. The error is the following:

Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/testygubbins/OO/test/header.php:15) in /Applications/MAMP/htdocs/testygubbins/OO/test/form.php on line 16.

What should I be doing to make it work?

header.php code:

<?php include 'class.user.php'; include 'class.Connection.php'; $date = date('Y-m-j'); ?> <html> <head> <link rel=StyleSheet href="css/style.css" type="text/css" media=screen> <title>Test</title> </head> <body> <div id="page"> 
include('header.php'); $name = $_POST['name']; $score = $_POST['score']; $dept = $_POST['dept']; $MyDB->prep("INSERT INTO demo (`id`,`name`,`score`,`dept`, `date`) VALUES ('','$name','$score','$dept','$date')"); // Bind a value to our :id hook // Produces: SELECT * FROM demo_table WHERE id = '23' $MyDB->bind(':date', $date); // Run the query $MyDB->run(); header('Location:index.php'); exit; 

The above code keeps giving me an issue with the redirect. The error is the following:

Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/testygubbins/OO/test/header.php:15) in /Applications/MAMP/htdocs/testygubbins/OO/test/form.php on line 16. 

Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/testygubbins/OO/test/header.php:15) in /Applications/MAMP/htdocs/testygubbins/OO/test/form.php on line 16.

I am totally flummoxed by this. Does anyone know what I should be doing to make it work?

EDIT

header.php code:

<?php include('class.user.php'); include('class.Connection.php'); $date = date('Y-m-j'); ?> <html> <head> <link rel=StyleSheet href="css/style.css" type="text/css" media=screen> <title>Test</title> </head> <body> <div id="page"> 
include('header.php'); $name = $_POST['name']; $score = $_POST['score']; $dept = $_POST['dept']; $MyDB->prep("INSERT INTO demo (`id`,`name`,`score`,`dept`, `date`) VALUES ('','$name','$score','$dept','$date')"); // Bind a value to our :id hook // Produces: SELECT * FROM demo_table WHERE id = '23' $MyDB->bind(':date', $date); // Run the query $MyDB->run(); header('Location:index.php'); exit; 

The above code keeps giving me an issue with the redirect. The error is:

Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/testygubbins/OO/test/header.php:15) in /Applications/MAMP/htdocs/testygubbins/OO/test/form.php on line 16. 

I am totally flummoxed by this. Does anyone know what I should be doing to make it work?

EDIT

header.php code:

<?php include('class.user.php'); include('class.Connection.php'); $date = date('Y-m-j'); ?> <html> <head> <link rel=StyleSheet href="css/style.css" type="text/css" media=screen> <title>Test</title> </head> <body> <div id="page"> 
include('header.php'); $name = $_POST['name']; $score = $_POST['score']; $dept = $_POST['dept']; $MyDB->prep("INSERT INTO demo (`id`,`name`,`score`,`dept`, `date`) VALUES ('','$name','$score','$dept','$date')"); // Bind a value to our :id hook // Produces: SELECT * FROM demo_table WHERE id = '23' $MyDB->bind(':date', $date); // Run the query $MyDB->run(); header('Location:index.php'); exit; 

The above code keeps giving me an issue with the redirect. The error is the following:

Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/testygubbins/OO/test/header.php:15) in /Applications/MAMP/htdocs/testygubbins/OO/test/form.php on line 16.

I am totally flummoxed by this. Does anyone know what I should be doing to make it work?

EDIT

header.php code:

<?php include('class.user.php'); include('class.Connection.php'); $date = date('Y-m-j'); ?> <html> <head> <link rel=StyleSheet href="css/style.css" type="text/css" media=screen> <title>Test</title> </head> <body> <div id="page"> 
Post Closed as "Duplicate" by user1592648, user3942918, Charles php
Question Protected by CommunityBot
include('header.php'); $name = $_POST['name']; $score = $_POST['score']; $dept = $_POST['dept']; $MyDB->prep("INSERT INTO demo (`id`,`name`,`score`,`dept`, `date`) VALUES ('','$name','$score','$dept','$date')"); // Bind a value to our :id hook // Produces: SELECT * FROM demo_table WHERE id = '23' $MyDB->bind(':date', $date); // Run the query $MyDB->run(); header('Location:index.php'); exit; 

The above code keeps giving me an issue with the redirect. The error is:

Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/testygubbins/OO/test/header.php:15) in /Applications/MAMP/htdocs/testygubbins/OO/test/form.php on line 16.

Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/testygubbins/OO/test/header.php:15) in /Applications/MAMP/htdocs/testygubbins/OO/test/form.php on line 16. 

I am totally flummoxed by this. Does anyone know what iI should be doing to make it work? Cheers

EDIT

header.php code:

<?php include('class.user.php'); include('class.Connection.php');  $date = date('Y-m-j'); ?> <html> <head> <link rel=StyleSheet href="css/style.css" type="text/css" media=screen> <title>Test</title> </head> <body> <div id="page"> 
include('header.php'); $name = $_POST['name']; $score = $_POST['score']; $dept = $_POST['dept']; $MyDB->prep("INSERT INTO demo (`id`,`name`,`score`,`dept`, `date`) VALUES ('','$name','$score','$dept','$date')"); // Bind a value to our :id hook // Produces: SELECT * FROM demo_table WHERE id = '23' $MyDB->bind(':date', $date); // Run the query $MyDB->run(); header('Location:index.php'); exit; 

The above code keeps giving me an issue with the redirect. The error is:

Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/testygubbins/OO/test/header.php:15) in /Applications/MAMP/htdocs/testygubbins/OO/test/form.php on line 16.

I am totally flummoxed by this. Does anyone know what i should be doing to make it work? Cheers

EDIT

header.php code:

<?php include('class.user.php'); include('class.Connection.php');  $date = date('Y-m-j'); ?> <html> <head> <link rel=StyleSheet href="css/style.css" type="text/css" media=screen> <title>Test</title> </head> <body> <div id="page"> 
include('header.php'); $name = $_POST['name']; $score = $_POST['score']; $dept = $_POST['dept']; $MyDB->prep("INSERT INTO demo (`id`,`name`,`score`,`dept`, `date`) VALUES ('','$name','$score','$dept','$date')"); // Bind a value to our :id hook // Produces: SELECT * FROM demo_table WHERE id = '23' $MyDB->bind(':date', $date); // Run the query $MyDB->run(); header('Location:index.php'); exit; 

The above code keeps giving me an issue with the redirect. The error is:

Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/testygubbins/OO/test/header.php:15) in /Applications/MAMP/htdocs/testygubbins/OO/test/form.php on line 16. 

I am totally flummoxed by this. Does anyone know what I should be doing to make it work?

EDIT

header.php code:

<?php include('class.user.php'); include('class.Connection.php'); $date = date('Y-m-j'); ?> <html> <head> <link rel=StyleSheet href="css/style.css" type="text/css" media=screen> <title>Test</title> </head> <body> <div id="page"> 
added 10 characters in body
Source Link
Drew
  • 3.2k
  • 9
  • 42
  • 63
Loading
Source Link
Drew
  • 3.2k
  • 9
  • 42
  • 63
Loading