p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   PHP FAQs (http://p2p.wrox.com/php-faqs-124/)
-   -   having trouble with header function (http://p2p.wrox.com/php-faqs/98736-having-trouble-header-function.html)

Truck35 March 20th, 2016 09:28 AM

having trouble with header function
 
[:confused:]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.


All times are GMT -4. The time now is 06:18 PM.

Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.