Page 1 of 2
another noob needs help :@ :banghead:
Posted: Mon Oct 31, 2011 2:17 am
by evan_lone
m facin' some problem, i alwys get the same file even after editing the file.
This is the code that i use to download the edited file:
Code: Select all
<?php $ipaddress = getenv(REMOTE_ADDR); $filename = "$ipaddress.txt";
$filepath = "./".$filename; header("Cache-control: private"); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Length: ' . filesize($filepath)); header('Content-Disposition: attachment; filename=' . $filename); ob_clean();
flush();
readfile($filename);
exit(done);
?>
Re: another noob needs help :@ :banghead:
Posted: Mon Oct 31, 2011 3:55 am
by social_experiment
What does the file edit script look like?
Re: another noob needs help :@ :banghead:
Posted: Wed Nov 02, 2011 9:46 am
by evan_lone
here it is:
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>webpad</title>
</head>
<body background="ntpdbg.png">
<body></body>
<?php $data = $_POST['webpad'];
$ipaddress = getenv(REMOTE_ADDR);
$myFile = "$ipaddress.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = "$data\n";
fwrite($fh, $stringData); fclose($fh);
echo "congrates ! Your data is saved ";?>
<a href="./paddwnld.php">here</a></html>
i got the string from a form.
Re: another noob needs help :@ :banghead:
Posted: Wed Nov 02, 2011 9:50 am
by evan_lone
here is the form:
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>WebPad</title>
</head>
<body background="ntpdbg.png">
<img src="./trans.png" alt="i" />
<body>
<p>
<h4>Type/Paste here !</h4>
</p>
<form action="webpad.php"
method="post"><textarea rows="5" cols="20" name="webpad" wrap="physical">Enter your favorite quote!</textarea><br/>
<input type="submit" name="save" value="Submit N Download"/>
<h4><a href="./abt/webpadabt.html">about</a><h4></body>
</html>
Re: another noob needs help :@ :banghead:
Posted: Wed Nov 02, 2011 9:57 am
by social_experiment
Try using the 'a' flag with fopen instead of the 'w' flag. The 'a' flag will move the file pointer to the end of the file so you can add (or append) to the file.
Re: another noob needs help :@ :banghead:
Posted: Wed Nov 02, 2011 10:35 am
by evan_lone
@social_experiment: actualy what i want is the file to be rewritten! Though i already tried the 'a' flag
but i 've to wait for ages to download the newly edited file(it always gives me the last downloaded(before editing) file)
if you could spare me a minute here is the link
http://loneapps.net16.net/loneapps/webpad/webpad.html
(please use a phone's browser as it is designed for small displays)
Re: another noob needs help :@ :banghead:
Posted: Wed Nov 02, 2011 11:30 pm
by social_experiment
evan_lone wrote:but i 've to wait for ages to download the newly edited file(it always gives me the last downloaded(before editing) file)
I tested it and it opened pretty quickly after i entered a quote, and it displayed the last value i entered
Re: another noob needs help :@ :banghead:
Posted: Wed Nov 02, 2011 11:52 pm
by evan_lone
social_experiment wrote:evan_lone wrote:but i 've to wait for ages to download the newly edited file(it always gives me the last downloaded(before editing) file)
I tested it and it opened pretty quickly after i entered a quote, and it displayed the last value i entered
i m a bad speaker, pardon me for writing too long, say i entered the qoute 'hello' first time i enter the site and download it the downloaded files contents will be 'hello' but if i again enter another value say 'bye' and download it the file's contents won't be 'bye' instead it would come as 'hello' which is the value i just entered before.
I've tried many things but every time i end up with the same problem or an err msg.
Of course you will get the new file but like i said only after waiting for the 'server to refresh' try it.
Re: another noob needs help :@ :banghead:
Posted: Thu Nov 03, 2011 12:15 am
by social_experiment
evan_lone wrote:say i entered the qoute 'hello' first time i enter the site and download it the downloaded files contents will be 'hello' but if i again enter another value say 'bye' and download it the file's contents won't be 'bye' instead it would come as 'hello' which is the value i just entered before.
I entered submitted the form with default content and when i viewed the text file i saw the correct text, then i used my browser button to go back and entered a new value, which when submitted and viewed is displayed correctly. I couldn't recreate the problem you describe.
evan_lone wrote:I've tried many things but every time i end up with the same problem or an err msg.Of course you will get the new file but like i said only after waiting for the 'server to refresh' try it.
Can you paste the error message if you receive it. If i receive the new message i entered i would assume the script is working. I don't quite understand what you mean by 'server to refresh' but i would say that's normal because the script is writing to a file which might take time.
Re: another noob needs help :@ :banghead:
Posted: Thu Nov 03, 2011 12:24 am
by evan_lone
or is it my device that is wrong!?
But what i guess(as a newbie) is that it is the server that is slow.
But thanks so much for givin' your precius time out here!
Regards.
Re: another noob needs help :@ :banghead:
Posted: Thu Nov 03, 2011 12:30 am
by social_experiment
evan_lone wrote:or is it my device that is wrong!?But what i guess(as a newbie) is that it is the server that is slow.
It's possible that the connection is slow, what type of connection do you use through the device?
Re: another noob needs help :@ :banghead:
Posted: Thu Nov 03, 2011 12:56 am
by evan_lone
social_experiment wrote:evan_lone wrote:or is it my device that is wrong!?But what i guess(as a newbie) is that it is the server that is slow.
It's possible that the connection is slow, what type of connection do you use through the device?
oh, we dont have fast connection here in manipur,

but i used edge connection, its pretty fast. And of course the 'congrates ! Your file is saved here'(hope you get me) page loads really fast so as the download. Did you got the file downloaded or displayed on the browser's window ? Once i managed the file to be displayed but at that time there was no problems, the browser always instantly displayed corectly every time i summit.
Re: another noob needs help :@ :banghead:
Posted: Thu Nov 03, 2011 1:05 am
by social_experiment
evan_lone wrote:Did you got the file downloaded or displayed on the browser's window ?
The browser gives an option that let's you either open it or save it, i opened it and saw it's contents.
Re: another noob needs help :@ :banghead:
Posted: Thu Nov 03, 2011 1:11 am
by evan_lone
social_experiment wrote:evan_lone wrote:Did you got the file downloaded or displayed on the browser's window ?
The browser gives an option that let's you either open it or save it, i opened it and saw it's contents.

please use a mobile browser(preferably opera mini or default for it was designed) to see the problem, please!
Re: another noob needs help :@ :banghead:
Posted: Thu Nov 03, 2011 1:26 am
by social_experiment
Tested it on the default browser on my mobile, got the quote i entered, my mobile however uses a fast connection as well.