Results 1 to 6 of 6

Thread: A random "1" at the end of the document?

  1. #1
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default A random "1" at the end of the document?

    A client of mine is keeping track of the people who visit his site by having them enter an email to view the content.
    I'm taking the email and writing it to the end of a .txt document, which I include on the admin page I created.
    Now, the issue is...whenn the .txt document is included, a "1" shows up emmediately after it.
    I checked the .txt file and the 1 isn't in the file itself.
    So that tells me two things:
    one, that it's because I'm including it
    and two, that it's not in the text document itself, and rather is a reaction from including the .txt document.

    Here's the code to write the email:

    PHP Code:
    $filename "emails.txt";

            
    $date date("F j, Y");

            
    $email stripslashes($_POST['email']);
            if (!
    $email) { $email "Not Available."; }

            
    $add "<p>".$date." -- ".$email."</p>\n\n";
            
    $add2 = @file_get_contents($filename).$add;

                
    $file = @fopen($filename"w+");
                @
    fwrite($file$add2);
                @
    fclose($file); 
    And here's the code to include the emails:

    PHP Code:
    $username "adminexample";
    $password "passwordexample"
    $self "index.php?page=logged_emails";

    if (
    $_POST['username'] != $username || $_POST['password'] != $password) {
    echo 
    $loginwrap.$self.$loginwrapbot;}
    else{
    echo
    include (
    "emails.txt");} 
    $loginwrap and $loginwrapbot are just parts of the form to login, and the styling around the form.

    Anyone know why the mysterious "1" shows up??

  2. #2
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    has nothing to with that code. Check your html

  3. #3
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    The code of the .txt document starts off as so:

    Code:
    <!-- BEGIN EMAIL LOG -->
    
    <h3>Email Log</h3>
    Then, the code to add the email to the bottom of the text document is above in my original post.

    The surrounding code does not contain any errors or 1's, as well, and the "1" only shows up when the text document is included.

    This is freaking weird!

  4. #4
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    Oh, I see it now
    PHP Code:
    $username "adminexample";
    $password "passwordexample"
    $self "index.php?page=logged_emails";

    if (
    $_POST['username'] != $username || $_POST['password'] != $password) {
    echo 
    $loginwrap.$self.$loginwrapbot;}
    else{
    include (
    "emails.txt");

    You had an extra echo in there

  5. #5
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    Thanks

  6. #6
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    glad to help

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
  •