View Single Post
  #1 (permalink)  
Old March 20th, 2016, 10:28 AM
Truck35 Truck35 is offline
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.
Reply With Quote