Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I need more help

    Hello,

    I sent a thread out yesterday about a form i was creating. I have got a form that is working correctly as far as it sends the email to me and forwards a thank you email to the client however when they press submit it is supposed to go to a thankyou.html with a brief message however it is producing the following error:

    Warning: Cannot modify header information - headers already sent by (output started at /homepages/1/d403557934/htdocs/contact.php:1) in /homepages/1/d403557934/htdocs/contact.php on line 29

    The contact.php file i have created has the following coding:

    PHP Code:
    <?php 
     $to 
    $_REQUEST['sendto'] ; 
     
    $from $_REQUEST['Email'] ; 
     
    $name $_REQUEST['Name'] ; 
     
    $headers "From: $from"
     
    $subject "Web Contact Data"
     
     
    $fields = array(); 
     
    $fields{"Name"} = "Name"
     
    $fields{"Company"} = "Company"
     
    $fields{"Email"} = "Email"
     
    $fields{"Phone"} = "Phone"
     
    $fields{"list"} = "Mailing List"
     
    $fields{"Message"} = "Message"
     
     
    $body "We have received the following information:\n\n"; foreach($fields as $a => $b){     $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } 
     
     
    $headers2 "From: [email]noreply@europeantextiles.co.uk[/email]"
     
    $subject2 "Thank you for contacting us"
     
    $autoreply "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 24 hours. If you have any more questions, please consult our website at www.europeantextiles.co.uk";
     
     if(
    $from == '') {print "You have not entered an email, please go back and try again";} 
     else { 
     if(
    $name == '') {print "You have not entered a name, please go back and try again";} 
     else { 
     
    $send mail($to$subject$body$headers); 
     
    $send2 mail($from$subject2$autoreply$headers2); 
     if(
    $send
     {
    header"Location: www.cash4usedclothing.co.uk/thankyou.html" );} 
     else 
     {print 
    "We encountered an error sending your mail, please notify [email]info@europeantextiles.co.uk[/email]"; } 
     }
    }
     
    ?>
    Where am i going wrong, i can see the light at the end of the tunnel but i just cant get there!

    I look forward to your help.
    Last edited by VIPStephan; 02-28-2012 at 02:55 PM. Reason: wrapped code in PHP BB tags

  • #2
    New Coder
    Join Date
    Feb 2012
    Location
    Finland
    Posts
    59
    Thanks
    3
    Thanked 9 Times in 9 Posts
    Try adding this at start of your PHP file

    Code:
    <?php 
    
    /*****************************/
    // Start the buffering of output, to avoid header errors.
    ob_start(); // "ob_gzhandler");
    /****************************/
    
     $to = $_REQUEST['sendto'] ; 
     $from = $_REQUEST['Email'] ; 
     $name = $_REQUEST['Name'] ; 
     $headers = "From: $from"; 
     $subject = "Web Contact Data";  
     $fields = array(); 
     $fields{"Name"} = "Name"; 
     $fields{"Company"} = "Company"; 
     $fields{"Email"} = "Email"; 
     $fields{"Phone"} = "Phone"; 
     $fields{"list"} = "Mailing List"; 
     $fields{"Message"} = "Message"; 
     
     $body = "We have received the following information:\n\n"; foreach($fields as $a => $b){     $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } 
     
     $headers2 = "From: noreply@europeantextiles.co.uk"; 
     $subject2 = "Thank you for contacting us"; 
     $autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 24 hours. If you have any more questions, please consult our website at www.europeantextiles.co.uk";
     
     if($from == '') {print "You have not entered an email, please go back and try again";} 
     else { 
     if($name == '') {print "You have not entered a name, please go back and try again";} 
     else { 
     $send = mail($to, $subject, $body, $headers); 
     $send2 = mail($from, $subject2, $autoreply, $headers2); 
     if($send) 
     {header( "Location: www.cash4usedclothing.co.uk/thankyou.html" );} 
     else 
     {print "We encountered an error sending your mail, please notify info@europeantextiles.co.uk"; } 
     }
    }
     ?>

    Don't know if this helps but hopefully!

    -Riku

  • #3
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Rkiu,

    Thanks for your reply, i managed to get it sorted just, it was daft really, i removed a space line between to bits of coding and it rectified itself... a little confused to be honest!

    Thank you again!

    Chris

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    The error will always tell you where to look. In this case, its the first line of contact.php indicating you have whitespace before <?php. No output to the browser can occur if you plan on sending headers, which includes session_start as well as errors.

  • #5
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    am not a coder just learning to code meanwhile who can help code my social network because some apsect of the php script is not working well?

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Quote Originally Posted by nordichuks View Post
    am not a coder just learning to code meanwhile who can help code my social network because some apsect of the php script is not working well?
    Whomever it is that you hire to do the work for you. This shouldn't have been posted in a way to hijack an existing thread.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •