File permission questions
Moderator: General Moderators
- akimm
- Forum Contributor
- Posts: 460
- Joined: Thu Apr 27, 2006 10:50 am
- Location: Ypsilanti Michigan, formally Clipsburgh
File permission questions
My purpose is to create a textfile that doesn't exist, consistent completely of form input, a content management system, I can't use mysql so I need to use flatfiles.
Is there anyway I can create a textfile in /somedirectory/somearticle
However I want the textfiles created as some submit these articles, like the first article to be article1.txt.
NOTE: I am not asking, nor do I want anyone to write code for me, I just need to know whether or not you can actually do what I'm trying to do.
Is there anyway I can create a textfile in /somedirectory/somearticle
However I want the textfiles created as some submit these articles, like the first article to be article1.txt.
NOTE: I am not asking, nor do I want anyone to write code for me, I just need to know whether or not you can actually do what I'm trying to do.
Didn't we already go over this? I remember like 3 threads about this only a week ago at the most. Did you forget? How come you can't use database? Are you scared they are going to be too hard? Files are more difficult to work with than databases if that's the case. Databases are MUCH easier to manage. File management can be pretty crappy.
Yes, it is possible. Read up on all the file functions
http://uk.php.net/manual/en/ref.filesystem.php
http://uk.php.net/manual/en/ref.filesystem.php
did you forget about all of these?
viewtopic.php?t=50369&highlight=
viewtopic.php?t=50445&highlight=
viewtopic.php?t=50452&highlight=
viewtopic.php?t=50369&highlight=
viewtopic.php?t=50445&highlight=
viewtopic.php?t=50452&highlight=
- akimm
- Forum Contributor
- Posts: 460
- Joined: Thu Apr 27, 2006 10:50 am
- Location: Ypsilanti Michigan, formally Clipsburgh
Yes
I did post this three times, and three times peoples help failed, must you be so terse, all I wish to know is if it's possible to do what I want to do, if you don't want to help don't come to this, sorry I don't know everything, and sorry the help that was provided wasn't sufficient to help out my moronic ass. I wish I could answer my questions, I wish the 150 inquiries on google could, but apparently I'm still stuck. I am a broke college student, I do not have the money to purchase the mysql database. Please just answer my question or be on your way, sorry i'm such a problem with my constant repost, perhaps I should just forget about this forum if that is such a burden.
No... it's not that you are a burden. Everybody here is happy to help. It's the fact that you have started like 4 or 5 threads to solve one problem. Everybody has been helpful to you and you call them rude. Still... I'm happy to help. Just don't understand why you are asking this question when it has been answered 4 or 5 times.
So, let's go back to your code that you posted already 4 times and we can try and get this resolved for you.
You must realize this is the internet, so things may come off as rude, but that's because there isn't a way to emphasize caring and concern other than this:
So, let's go back to your code that you posted already 4 times and we can try and get this resolved for you.
You must realize this is the internet, so things may come off as rude, but that's because there isn't a way to emphasize caring and concern other than this:
- akimm
- Forum Contributor
- Posts: 460
- Joined: Thu Apr 27, 2006 10:50 am
- Location: Ypsilanti Michigan, formally Clipsburgh
I call people rude
When they talk down to me, scold me as you did. I understand what you're saying with the multiple posts, but never did any help I receieve solve my problems, I then began to rewrite the code on my own, and came to the conclusion that even with constant checks with php.net, and other sources, and still the problem was not solved.
- akimm
- Forum Contributor
- Posts: 460
- Joined: Thu Apr 27, 2006 10:50 am
- Location: Ypsilanti Michigan, formally Clipsburgh
Well excuse my misunderstanding
I guess you are right about that.
- akimm
- Forum Contributor
- Posts: 460
- Joined: Thu Apr 27, 2006 10:50 am
- Location: Ypsilanti Michigan, formally Clipsburgh
I want a program that
I have this form, on 5.htm. With 4.php I have a counter iterate and from that iteration I take the number and add it to article, idealy, the first article submitted should be article1.txt and so forth. I have tried a+ w+ and now x+ to try to mittigate the writing process of this article to the directory.
Code: Select all
<form method='POST' action='4.php'>
<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>Code: Select all
<?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 = '/articles/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'];
$handle = fopen($file, 'x+');
// 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 {
fwrite($handle, $user, 'w+') . fclose($handle);
}
?>It seems like it should work.
Except of this bit:
which should be:
Except of this bit:
Code: Select all
// recognize what i want from user
// variable to concocatanate to append user info
$user = $_POST['name'] . $_POST['email'] . $_POST['article'];
$handle = fopen($file, 'a+');
// 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 {
fwrite($handle, $user, 'x+') . fclose($handle);
}Code: Select all
// recognize what i want from user
// variable to concocatanate to append user info
$user = $_POST['name'] . $_POST['email'] . $_POST['article'];
if(file_exists($file))
die();
$handle = fopen($file, 'a+');
// start an iteration that will add 1,2,3,4,5,6 and so on to each article
// added
fwrite($handle, $user);
fclose($handle);DO NOT START TOPICS ON THE SAME SUBJECT!!!
Use your other thread to continue the discussion.
If noone could help int he previous topics, no need to start a new one
Use your other thread to continue the discussion.
If noone could help int he previous topics, no need to start a new one
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:3. Do not make multiple, identical posts. This is viewed as spam and will be deleted.