SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    vi
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Header location issue. small piece of code can anyone take a look

    My Error Output is this:
    Warning: Cannot modify header information - headers already sent by (output started at city-search.php:1) in city-search.php on line 65

    What I'm I missing in the code, I can't seem to get these. It works excellent in Localhost, but in production. Error above.
    PHP Code:
    <?php
    // MG CREATED THIS SIMPLE REGISTRATION PHP FOR THAT GOES TO ONE SPECIFIC USER.
    // WILL TEST FORM REGSITRATION NG 07-2011
    //If the form is submitted
    if(isset($_POST['submit'])) {

        
    //Check to make sure that the name field is not empty
        
    if(trim($_POST['name']) == '') {
            
    $hasError true;
        } else {
            
    $name trim($_POST['name']);
        }

        
    //Check to make sure that the subject field is not empty
        
    if(trim($_POST['subject']) == '') {
            
    $hasError true;
        } else {
            
    $subject trim($_POST['subject']);
        }

        
    //Check to make sure sure that a valid email address is submitted
        
    if(trim($_POST['email']) == '')  {
            
    $hasError true;
        } else if (!
    eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$"trim($_POST['email']))) {
            
    $hasError true;
        } else {
            
    $email trim($_POST['email']);
        }
        
    //Check to make sure comments were entered
        
    if(trim($_POST['message']) == '') {
            
    //$hasError = true;
            
    $comments == 'Have No Friends';
        } else {
            if(
    function_exists('stripslashes')) {
                
    $comments stripslashes(trim($_POST['message']));
            } else {
                
    $comments trim($_POST['message']);
            }
        }

        
    //If there is no error, send the email
        
    if(!isset($hasError)) { 
            
    //$emailTo = 'regina@shushmedeals.com';
            //$emailTo = 'reginabyrd32@yahoo.com';
            
    $emailTo 'mp3@danjaproduction.com';         
            
    //$emailBcc = 'ganja99@netzero.net';
            //$emailBcc = 'info@danjaproduction.com';  
            //$emailBcc = 'ganja99@netzero.net';    
            //Put your own email address here
            
    $body "Location: $name \n\nEmail: $email \n\nShushMeDeals Sign-up Info:\n $comments";
        
            
    // To send HTML mail, the Content-type header must be set
        
            
    $headers  'From: ShushMeDeals.com City Location  sign-up - '.$name.'' "\r\n" 'Reply-To: ' $email "\r\n" .'Bcc: print@extremeatlanta.com'
            
    //$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
            //$headers .= 'Bcc: info@danjaproduction.com' . "\r\n";

            
    mail($emailTo$subject$body$headers);
            
    $emailSent true;
            if(
    $emailSent true) {
                
    setcookie("location"$name);

                
    //echo '<script type="text/javascript">
               //       window.location = "index.php?option=com_enmasse&controller=deal&task=today&locationName='.$name.'"
               //      </script>';
            
    }
        }
    }
    ?>
    Last edited by SpacePhoenix; Sep 23, 2011 at 10:06. Reason: swapped code tags for php tags around php script

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    (output started at city-search.php:1)

    This says there's a problem on your first line. Is there a space character before the < in <?php ?
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,862
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    If it doesn't look like there is a space before the < then there might be a byte order mark there causing the problem.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    vi
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb What do you mean by byte order mark

    I can't locate what makes this header modfiy error show up.
    But I am somewhat stoked on such simeple issues.
    I can't seem to figure out what's the issue.

  5. #5
    SitePoint Zealot blackberryfan's Avatar
    Join Date
    Nov 2010
    Location
    middleOnowhere, South Africa.
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what is at line 65?

    remove the following code that you have commented out near the end:
    Code:
    //echo '<script type="text/javascript">
     //       window.location = "index.php?option=com_enmasse&controller=deal&task=today&locationName='.$name.'"
     //      </script>';
    It has something to do with the </script> ending, it is taking the ' literally


Tags for this Thread

Bookmarks

Posting Permissions

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