here is my latest version of the code
Code: Select all
<html>
<head>
<title>Adda-article</title>
<STYLE TYPE='text/css'>"
@import url(style.css);\n";
</STYLE>
<body>
<?php
$date = date(' l n/d/y g:i a');
echo $date;
?>
<form action='<?php $_SERVER['PHP_SELF']; ?> method='POST'>
<p><b>Your name</b>
<input type='text' name='name' size='30'></p>
<p><b>Your email</b>
<input type='text' name='email' size='30'></p>
<p><b>article</b>
<TEXTAREA NAME='article' COLS='120' ROWS='20' WRAP='virtual'></TEXTAREA></P>
<p><input type='submit' name='submit' value='submit your aritlce'></p>
<?php
$myfile = "count.txt";
//we assign our file name to the variable we'll use to handle it
if(file_exists($myfile))//if the file exists
{ //we run our counter script
$var = fopen( $myfile,'r+');
//opens in read and write mode our file
$visits = fread($var,filesize($myfile));
//puts the content of the file for its whole lenght
rewind( $var );
//resets the file position indicator to the beginning
$visits++; //increments the actual number of vists by 1
fwrite($var, $visits);
//writes on the variable the actual (incremented) value
fclose($var);//closes our file reference
}
else
{
print "File $myfile doesn't exist...";
Die();
//if the file doesn't exist prompts a warning and kills the script
}
$file = '/article/article' . $visits . '.txt';
if ($_POST['name'] == "") {
echo "please provide a name";
}
if ($_POST['email'] == "") {
echo "Please provide an email";
}
if ($_POST['article'] == "") {
echo "If you're submitting an article, you'd need the actual article. Try again ";
}
// recognize what i want from user
// variable to concocatanate to append user info
$user = $_POST['name'] . $_POST['email'] . $_POST['article'];
// start an iteration that will add 1,2,3,4,5,6 and so on to each article
// added
if(file_exists($file)) {
Die();
} else {
fopen($file, 'a') . fwrite($file, $user, 'w') . fclose($file);
}
?>