A PHP Error was encountered

Severity: 8192

Message: Methods with the same name as their class will not be constructors in a future version of PHP; Waterfall_Cache has a deprecated constructor

Filename: _common/waterfall_cache.php

Line Number: 47

A PHP Error was encountered

Severity: 8192

Message: Methods with the same name as their class will not be constructors in a future version of PHP; Cache_System has a deprecated constructor

Filename: _common/waterfall_cache.php

Line Number: 194

A PHP Error was encountered

Severity: 8192

Message: Methods with the same name as their class will not be constructors in a future version of PHP; Memcache_Cache_System has a deprecated constructor

Filename: _common/waterfall_cache.php

Line Number: 275

A PHP Error was encountered

Severity: 8192

Message: Methods with the same name as their class will not be constructors in a future version of PHP; Filesystem_Cache_System has a deprecated constructor

Filename: _common/waterfall_cache.php

Line Number: 440

A PHP Error was encountered

Severity: 8192

Message: Methods with the same name as their class will not be constructors in a future version of PHP; APC_Cache_System has a deprecated constructor

Filename: _common/waterfall_cache.php

Line Number: 628

Writing data to a text file

Writing data to a text file

By ServerWatch Staff (Send Email)
Posted May 11, 1999


Ian Stallings
While writing a online signup form I decided to write some of the data to a text file for security reasons. I could've used a database, but the overhead isn't worth it and I only need notepad to open a text file. So, on to the code.

While writing a online signup form I decided to write some of the data to a text file for security reasons. I could've used a database, but the overhead isn't worth it and I only need notepad to open a text file. So, on to the code.

First we declare the textfile to be used and if it doesn't exist create it using this:

<%
LogFile = Server.Mappath("log.txt")
Set LogFileObj=Server.CreateObject("Scripting.FileSystemObject")


Set OutStream=LogFileObj.OpenTextFile(LogFile, 8, TRUE)

New_line = Request.Form("UserName") & Chr(13) & Chr(10)

OutStream.WriteLine(New_line)
TextFile.Close
%>

Now we can submit the info we want to collect from a form:

<html>
<head>
</head>
<body>
<form action="writetext.asp" method="post">
Username:<input type="text" size="20" name="UserName">
<input type="submit" name="submit">
</body>
</html>

For this script to work it must have write permission. The text file will be created in the same directory as the script. If you have questions or article ideas feel free to drop me a line.

Page 1 of 1


Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.


 

 


Thanks for your registration, follow us on our social networks to keep up-to-date