Member Avatar for evilbenking

i need a perl code that will take a the input form my 1 question form (name) and print it on a new line with <br> after it in a text file (submit.txt) please can someone either write one up for me as simple as is posible or somthing, o and it has to be Appending so it adds it to the old data, i tried writing one but it failed miserably and my server told me to go find a person to do it for me so can anyone help??

Recommended Answers

All 2 Replies

Here's a simple bit of code I put together:

#!/usr/bin/perl

use strict;

use CGI qw(:standard);

my $query = new CGI;

my %vars;

foreach my $key (sort {$a <=> $b} $query->param())
{
	$vars{$key} = $query->param($key);
}

print "content-type: text/html\n\n";

if(open(FILE, ">>testFile.txt"))
{
	print FILE "$vars{'data'}<br>";
	close(FILE);
	
	print "Success";
}
else
{
	print "Fail";
}

exit;

This code assumes that you are wanting the information from the field named "data" saved in the file.

Member Avatar for evilbenking

Here's a simple bit of code I put together:
thank you, that code will save me soo much time :!: :cheesy:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.