PDA

View Full Version : A random "1" at the end of the document?



alexjewell
08-10-2006, 06:17 PM
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:



$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:



$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??

blm126
08-10-2006, 06:20 PM
has nothing to with that code. Check your html

alexjewell
08-10-2006, 06:25 PM
The code of the .txt document starts off as so:



<!-- 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!

blm126
08-10-2006, 06:27 PM
Oh, I see it now


$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

alexjewell
08-10-2006, 06:30 PM
Thanks
:)

blm126
08-10-2006, 06:32 PM
glad to help