okey i have upload my site everything works just fine except my contact form
here's my code

FYI - Im very new to the php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<?php

    $user_name = $_POST["NameBox"];
    $user_contact = null;
    $user_contact=$_POST["ContactBox"];
    $comment = $_POST["msgbox"];

    if($user_contact==null)
    {
        $user_contact = "Not provided";

    }


    $to = "mymail@domain.com";
     $subject = "Message From Web";
     $body = "Contact name is = $user_name | Contact number is = $user_contact | user comment is = $comment";

     mail($to, $subject, $body);

     header( 'Location:http://www.masconsolidated.com/confirmation.html');


?>
</body>
</html>

when i submit the form im getiing a error like

Warning: Cannot modify header information - headers already sent by (output started at /home/masconso/public_html/processData.php:10) in /home/masconso/public_html/processData.php on line 30

i can't figure it out..please help me (sample code will be better)
thanks

Member Avatar for diafol

You can't send headers after output (html, whitespace, php-derived html, php errors etc).

Try this:

<?php
    $user_name = $_POST["NameBox"];
    $user_contact = null;
    $user_contact=$_POST["ContactBox"];
    $comment = $_POST["msgbox"];
    if($user_contact==null)
    {
        $user_contact = "Not provided";
    }
    $to = "mymail@domain.com";
     $subject = "Message From Web";
     $body = "Contact name is = $user_name | Contact number is = $user_contact | user comment is = $comment";
     mail($to, $subject, $body);
     header( 'Location:http://www.masconsolidated.com/confirmation.html');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>

I can't see why you've got html here anyway. If you redirect, you don't see the page. Also - you may want to validate post input.

okey i have put only this lines for my php code

<?php
    $user_name = $_POST["NameBox"];
    $user_contact = null;
    $user_contact=$_POST["ContactBox"];
    $comment = $_POST["msgbox"];    
    if($user_contact==null)
    {
        $user_contact = "Not provided";
    }   
    $to = "mymail@domain.com";
    $subject = "Message From Web";
    $body = "Contact name is = $user_name | Contact number is = $user_contact | user comment is = $comment";
    mail($to, $subject, $body); 
    header("Location:confirmation.html");    
?>

is it necessary to put
header("Location:confirmation.html");
exit(); //at the end

Member Avatar for diafol

It's good practice to do so.

If this solves your problem - mark it solved. :)

yes it is.. many thanks for diafol

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.