Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP FAQs
| Search | Today's Posts | Mark Forums Read
PHP FAQs This moderated forum is where our PHP experts answer some of the questions they see asked most frequently in the other PHP forums. You cannot post other messages here, use the other PHP forums for that.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP FAQs section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old March 20th, 2016, 09:28 AM
Authorized User
Points: 132, Level: 2
Points: 132, Level: 2 Points: 132, Level: 2 Points: 132, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2012
Posts: 25
Thanks: 3
Thanked 0 Times in 0 Posts
Question having trouble with header function

I am having trouble with using the header function. When a run my php script I get the following error: "Warning: Cannot modify header information - headers already sent by..." I read that there can be no output before the function call. I don't see anything wrong with my code. Any help would be apperciated.

Here is my code:
PHP Code:
session_start();
require_once(
'Test_Input.php');


if(!isset(
$_SESSION['Form_First_Name']) || !isset($_SESSION['Form_Last_Name']) || !isset($_SESSION['Form_Email']) || !isset($_SESSION['Form_Message']))
{
    
$_SESSION['Form_First_Name'] = '';
    
$_SESSION['Form_Last_Nameorm'] = '';
    
$_SESSION['Form_Email'] = '';
    
$_SESSION['Form_Message'] = '';



if(isset(
$_POST['Clear']) && $_POST['Clear'] == 'clear')
{
    
$_SESSION['Form_First_Name'] = '';
    
$_SESSION['Form_Last_Nameorm'] = '';
    
$_SESSION['Form_Email'] = '';
    
$_SESSION['Form_Message'] = '';
    unset(
$_SESSION['name_Switch']);
    unset(
$_SESSION['Form_Email_Switch']);
    
//header('location:Contact_Form.php');
}

$response $_POST['Response'];
$image_request $_POST['DB_Response'];
$first_name $_SESSION['Form_First_Name'] = $_POST['First_Name'];
$last_name $_SESSION['Form_Last_Name'] = $_POST['Last_Name'];
$email $_SESSION['Form_Email'] = $_POST['Email'];
$_SESSION['Form_Message'] = $_POST['Message'];


$first_name_result Test_Input::name_validation($first_name);
var_dump($first_name_result);
$last_name_result Test_Input::name_validation($last_name);
$email_result Test_Input::email_validation($email);

if(!
$first_name_result || !$last_name_result )
{
    
$_SESSION['Name_Switch'] = false;
    
header('location:Contact_Form.php');
}

if (!
$email_result)
{
    
$_SESSION['Form_Email_Switch'] = false;
    
header('location:Contact_Form.php');
}

if(
$response != $image_request)
{
     
    
//unset($_SESSION['Form_Switch']);
    
unset($_SESSION['Email_Switch']);
    
header('location:Contact_Form.php');
}

else 
{
    global 
$first_name;
    global 
$last_name;
    global 
$email;
    
$message 'FROM: '.$first_name.' '.$last_name.' \n\n'$_POST['Message'];
    
$to 'admin@showlove-productions.com';
    
$subject 'Show Love Production Contact Form';
    
$headers $email;
    
mail($to$subject$message$headers);
    
$_SESSION['Email_Switch'] = true;
    unset(
$_SESSION['Form_First_Name']);
    unset(
$_SESSION['Form_Last_Name']);
    unset(
$_SESSION['Form_Email']);
    unset(
$_SESSION['Form_Message']);
header('location:Contact_Form.php');

I mainly concerned why my header function calls are not working.


Similar Threads
Thread Thread Starter Forum Replies Last Post
trouble with format-date() function gib65 XSLT 3 March 12th, 2014 05:25 PM
VB2005 trouble returning structure from function MikeCS Visual Basic 2005 Basics 1 November 29th, 2006 07:45 PM
Header Function Problem. changusee2k PHP How-To 1 September 27th, 2006 02:45 AM
How to call javascript function from VB function vinod_yadav1919 VB How-To 0 February 13th, 2006 06:03 AM
trouble with header function trangd Beginning PHP 1 July 24th, 2004 06:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.