Page 1 of 1

Logging the output of forms to text file

Posted: Tue Nov 18, 2003 9:05 pm
by ali
Hi there.I really need help about something.I'm the webmaster of digitaldummies.com.But I do not know programming in PHP.All I want is a simple script that stores the user's email address in a text file whenever someone types in their email address.Actually it sort of subscribes them for my newsletter.But I have gone half mad trying to do that.I've tried all of the free scripts found on the internet but none of them works.I dunno what I am doing wrong.Will someone please help me?
Thanks.:wink:
@li.

Posted: Tue Nov 18, 2003 9:09 pm
by Paddy
Post the code of what you have tried so far.

Posted: Tue Nov 18, 2003 9:12 pm
by ali
Here's the code of my form:
<FORM NAME="Form" METHOD=POST ACTION="add.php3">


<input type=hidden name="redirect" value=
"http://www.digitaldummies.coolfreehost.com/1.html">


<B><font color="red">Subscribe to our free <b>Computer Viruses'</b> Magazine:</font>

<input type="TEXT" name="01)add" value="your email here" size=17>&nbsp;&nbsp;&nbsp;&nbsp;
<center><input type="submit"></center>

</form>

And here's the code of my recently tried PHP program:

<?php
######################################################################
# FORM DATA COLLECTOR
# Filename: DataCollector.php
# Created: 23/06/2003
# Modified: 23/06/2003
# ==============
# Copyright (c) 2003 by Ashley Young (ash@evoluted.net)
# http://evoluted.net
# ==============
#
# Description
# ===========
# Saves data sent to the form either by POST or GET to a file specified
# below, CSV form. It allows multiple data files to save the data to and
# there is no limit on the number of fields stored.
#
# Usage
# =====
# The only thing that requires changing in this file
# is the paths to the data files. You then access the file like so:
#
# data.php?n=DATA&1=first_item_to_save&2=second_item&3=third etc
#
# Replacing DATA with a number from below relating to the datafile
# you wish to save the information in
#
# The file saves all data specified by POST or GET in the order which
# it is presented to the file. The first variable being saved in the
# first column, second variable in the second column and so on. It is
# however assuumed that the first variable supplied will be specifying
# the datafile number and the variable will be called 'n'.
#
# Variables
# =========
######################################################################
$data[0] = "file.txt";
$data[4] = "second.txt";
$data[1] = "l.txt";
$data[2] = "/l.txt"; // Just add more as required

######################################################################
# DO NO CHANGE ANYTHING BELOW THIS POINT
######################################################################
if(!$fp = fopen($data[$_REQUEST['n']], "a")) die ("Cannot open data file");

array_shift($_REQUEST);
$size = sizeof($_REQUEST);
for($i=0; $i<$size; $i++) {
$str = $str . array_shift($_REQUEST);
if(!($i==($size-1))) {
$str = $str . ", ";
}
}
fwrite($fp, $str . "\n\r");
echo "<p>Thank You</p><p>The data was successfully saved.</p>";
?>

Posted: Tue Nov 18, 2003 10:41 pm
by infolock
first of all, if you don't understand what that code is trying to do, i suggest you read this article :

http://www.onlygeeks.com/read/19

otherwise, there are all kinds of documentation on this subjected located here:

http://www.php.net/manual/en/function.fwrite.php

on your left you will find some other function lists that may spark your attention, along with some user responses at the end of the page. hope that helps.

Posted: Tue Nov 18, 2003 11:35 pm
by ali
Thanks a lot,but actually my problem is that its just impossible for me to understand PHP.What I want is that someone would give me a correct version of that script I gave above or to give me a new script.I don't have any time to learn PHP.

Posted: Tue Nov 18, 2003 11:46 pm
by infolock
then i'd suggest posting this question in this forum :

viewforum.php?f=26

is specifically for people who need volunteer work done. This is more of a help channel :P

Posted: Wed Nov 19, 2003 2:55 am
by twigletmac
Moved this to the Volunteer work forum. Don't post in PHP - Code if you don't want to learn anything about PHP.

Mac