Logging the output of forms to text file

Looking for volunteers to join your project? Need help with a script but can't afford to pay? Want to offer your services as a volunteer to build up your portfolio? This is the place for you...

Moderator: General Moderators

Post Reply
ali
Forum Newbie
Posts: 15
Joined: Tue Nov 18, 2003 9:05 pm
Location: Pakistan

Logging the output of forms to text file

Post 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.
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post by Paddy »

Post the code of what you have tried so far.
ali
Forum Newbie
Posts: 15
Joined: Tue Nov 18, 2003 9:05 pm
Location: Pakistan

Post 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>";
?>
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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.
ali
Forum Newbie
Posts: 15
Joined: Tue Nov 18, 2003 9:05 pm
Location: Pakistan

Post 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.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply