PDA

View Full Version : need some help



ch1zra
Jul 16th, 2005, 08:15 PM
hi all :)

I kinda need something but I don't know can it be done in javasctipt... or is this section of forum the right place to ask...
Ok, here's what I need. I have on my page this :

http://www.metalserbia.org/ch1zra/stuff/mailsend.png


Now, what I want is, instead of sending me mails (through some free sevrices), can text from "field 1" and "field 2" be written in some .txt file on my server ??

like, when someone presses the "- send -" button, that script writes this into eg. mail.txt :




--------------------------------
from : field 1

date : date (this only is possible :) )

msg : field 2

--------------------------------



thanx in advance :]

Taylor_1978
Jul 16th, 2005, 08:23 PM
Hi,

What you are requiring is 'Server Side' not 'Client Side'...

If your server/hosting allows PHP, see that forum.

Also.. "need help" really isn't an appropriate subject.. we all need help that's why we post messages. You need to specify in your subject line what it is you need help with so that people don't waste time clicking a message to find it is something they cannot help you with. :) Just a handy hint, and I also beieve it is part of the posting rules and guidelines.

Kickin
Jul 17th, 2005, 01:50 PM
Like Taylor said, this needs to be done from the server side, not with javascript, but yes, it can be done. If you were to use perl, it would look like this...


In the html page you would add:


<form name="myform" action="http://www.mywebsite.com/sendmail.pl" method="post">
<input type="text" size="20" name="email">
<textarea rows="6" cols="50" name="comments" wrap="virtual"></textarea>
<input type="submit" value="Send Email"></form>



The sendmail.pl file would look like this:


#!/usr/local/bin/perl
use CGI ':standard';
use CGI::Carp qw(fatalsToBrowser);
my $email = param('email');
my $comments = param('comments');


open (LOG, ">>../emails.txt") || Error('open', 'file');
print LOG "Email from $email who said $comments\n";
close (LOG);

print "Content-type:text/html\n\n";
print "<HTML><HEAD>\n";
print "<TITLE>Email sent</TITLE>\n";
print "</HEAD>\n";
print "<h2>Thank you, your email has been sent.<br></h2>\n";
print "</body></html>";
exit;


This is meant to be very basic, there are a lot of things you can change to make it look better or do more, but this should get you on the right track.

ch1zra
Jul 18th, 2005, 04:08 AM
hmm.. I have a plain html page... so I guess that that is a problem, right ??

also, I've been told that what I need is a regular mail form, but redecorated to instead of sending mail, saves it to a certain file.

but you people figured that out already :)

Kickin
Jul 18th, 2005, 10:58 AM
That depends on what you mean by "have a plain html page". If you mean your webhost won't allow perl or php, then yes it is a problem. You may need to discuss it with them, perhaps you can upgrade to a different package that allows these languages. Depends on how bad you want to to write to a file.

little_toaster
Jul 18th, 2005, 11:46 AM
using the TextStream object! [http://www.w3schools.com/asp/default.asp]tryhere[/URL]

with this object you can have your form write to a .txt file or .html format.

:thumbsup:

ch1zra
Jul 19th, 2005, 02:00 AM
okay...
i got this snippet @ Hawkee (http://www.hawkee.com)


<?php

$myemail = '[email protected]';

$op = $_POST[op];

switch($op)
{
case 'contact':

$name = $_POST[name];
$email = $_POST[email];
$subject = $_POST[subject];
$text = $_POST[text];

$referer = $_POST[referer];
$remote_host = $_SERVER[REMOTE_ADDR];
$server = $_SERVER[SERVER_NAME];
$browser = $_SERVER[HTTP_USER_AGENT];

$header = "From: $email\r\nReply-To: $email\r\n";

$message = "
Referer: $referer
Site: $server
Remote Host: $remote_host
Remote Browser: $browser

$text
";

if(mail($myemail, "Contact form: $subject", $message, $header))
{
$status = "Thank you for your Feedback!!<br><br>";
}

break;
}

?>

<?php print $status; ?>

<form method="post" action="<?php print $_SELF; ?>">
<input type="hidden" name="op" value="contact">
<input type="hidden" name="referer" value="<?php print $_SERVER[HTTP_REFERER]; ?>">
Name<br><input name="name" size="35" value=""><br>
E-mail address<br><input name="email" size="35" value=""><br>
Subject<br><input name="subject" size="35" value=""><br>
<br>Message<br><textarea name="text" cols="50" rows="10"></textarea><br><br>
<input type="submit" value="Send message!">



then I asked some guys @ undernet for some help, and they gave this link (http://www.free2code.net/plugins/articles/read.php?id=84).
then I asked them can the snippet above be modified to write the contents of fields into a .txt, on a server, and they said it can be done easily. then I asked them to help me, but they said they were kinda bussy with some stuff...

so, can someone here modify the code for me please ??
I would really appreciate it.