Click here to Skip to main content
15,893,190 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
When I make a questionssheet and I want php to save it in a .txt data, there always just the answers of the last person.
Code:
PHP
if ($_GET['reason'] <>"")
{
$handle=fopen ("answer.txt", "w");
fwrite ($handle, $_GET['reason']);
fwrite ($handle, "|");
}
	else
{
	echo "Please give the reason!". "<br />";
} 
?>


Did I forget something?
I think the problem is, that it always overwrite the last one.
Posted
Updated 25-Dec-11 8:08am
v5
Comments
Dalek Dave 24-Dec-11 19:49pm    
Edited for code block
Sergey Alexandrovich Kryukov 24-Dec-11 19:49pm    
You forgot to think; and this is not curable.
--SA
Chi Ller 24-Dec-11 19:54pm    
ahahah very very funny
it´s just a part of the code theres already the part where´s the 'reason'
if i knew the answer, i wouldn´t ask...
1.think->you forgot
2.write->you´ve done first
Sergey Alexandrovich Kryukov 25-Dec-11 14:48pm    
Sure, I know it's not very useful, but I though you could take the hint.
To suggests what can you do on server side, one would need to know what you try to do on client side.
In other words, there is not a question here -- you don't share important information.

So the short answer will be:
1) on client side, post (not "get", by the way) all you need (not just the latest, etc.)
2) on server side, process it properly.

In other words, just plan what do you need and implement it. You question does not help here.
--SA
Chi Ller 25-Dec-11 15:20pm    
i´ve tried it with post but then it won´t create a .txt file

I don't know php but looks like you are opening a file to write to and not append. You could also try giving each file a unique name so that you are creating a file for each user/answer set.
 
Share this answer
 
v2
I want more then my last salary ;P
Regards.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900