Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 5 of 5
  1. #1

    Default PHP Contact Us Headers problem

    I coded this with the help of a tutorial and I changed a few things around but now recieve this error:
    Warning: Cannot modify header information - headers already sent by (output started at /home/mounta1n/public_html/PHP/sendmail.php:18) in /home/mounta1n/public_html/PHP/sendmail.php on line 51
    Code:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Contact Us</title>
    <link href="main.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <div id="main">
    <form method="post" action="sendmail.php"><h1>Contact Us</h1>
      <p>Email:  
        <input name="email" type="text" />
        <br />
        Subject:
        <input type="text" name="title" />
      <br />
        Message:<br />
        <textarea name="message" rows="15" cols="40">
        </textarea>
        <br />
        <input type="submit" />
      </p>
    </form>
    </div>
    <div id="banner"></div>
    </body>
    </html>
    <?php
      $email = $_REQUEST['email'] ;
      $message = $_REQUEST['message'] ;
      $title = $_REQUEST['title'] ;
     
      if ( preg_match( "/[\r\n]/", $name ) || preg_match( "/[\r\n]/", $email ) ) {
       ?>
            <html>
        <head><title>Excuse me,</title></head>
        <body>
        <h1>Nice try,</h1>
        <p>
       But no.
        </p>
        </body>
        </html>
        <?php
      }
      if (!isset($_REQUEST['email'])) {
        header( "Location: http://www.example.com/feedback.html" );
      }
      elseif (empty($email) || empty($message)) {
        ?>
       <html>
       <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Contact Us</title>
    <link href="main.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <div id="main">
    <form method="post" action="sendmail.php"><h1>Contact Us</h1><br />
    <h6>Oops you missed something, try again.</h6>
      <p>Email:  
        <input name="email" type="text" />
        <br />
        Subject:
        <input type="text" name="title" />
      <br />
        Message:<br />
        <textarea name="message" rows="15" cols="40">
        </textarea>
        <br />
        <input type="submit" />
      </p>
    </form>
    </div>
    <div id="banner"></div>
    </body>
    </html>
        <?php
      }
      else {
         mail( **********@*******.co.uk, "Mounta1nGoat.co.uk Title: $title",
        $message, "From: $email" );
      header( "Location: http://www.mounta1ngoat.co.uk/PHP/thanks.html" );
      }
    ?>
    Could somebody help out please?
    View My DeviantART Gallery

    My new portfolio site is coming soon!

  2. #2
    Join Date
    Nov 2006
    Location
    Narrich
    Posts
    5,687
    Tokens
    0
    Habbo
    Jamesy...

    Latest Awards:

    Default

    PHP Code:
     header"Location: http://www.mounta1ngoat.co.uk/PHP/thanks.html" ); 
    has to be above the <head></head> tags
    Ex-janitor. Might pop in from time to time, otherwise you can grab all my information from http://jamesy.me.uk/

  3. #3

    Default

    Sorry but where exactly above the head tags? This is my first time coding something that actually works in PHP...
    View My DeviantART Gallery

    My new portfolio site is coming soon!

  4. #4
    Join Date
    Aug 2009
    Location
    South Wales.
    Posts
    377
    Tokens
    50

    Default

    Code:
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Contact Us</title>
    <link href="main.css" rel="stylesheet" type="text/css" />
    </head>
    thats where the head tags are.


  5. #5
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    Actually it should be before ANY text, whitespace, or anything that outputs to the browser.

    Quote Originally Posted by Jamesy View Post
    PHP Code:
     header"Location: http://www.mounta1ngoat.co.uk/PHP/thanks.html" ); 
    has to be above the <head></head> tags

Posting Permissions

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