#!/bin/perl
# tellfriend.pl

use strict;

use CGI qw(:standard);
use myHTML;

#print header();

my $action = param('action');
my $mailad = param('mail');
my $from   = param('from');

p "<html>";
p "<head>";
p "<title>Weiterempfehlen</title>";
p "</head>";
p "<body>";

if ($action eq "form") {
	# Formular anzeigen
	p2 "<form action='./tellfriend.pl?action=send' method='post'>",
	   " <table>",
	   "  <tr>",
	   "   <td>An</td>",
	   "   <td><input type='text' name='mail'></td>",
	   "   <td>eMail Adresse angeben!</td>",
	   "  </tr>",
	   "  <tr>",
	   "   <td>Von</td>",
	   "   <td><input type='text' name='from'></td>",
	   "   <td>Name angeben!</td>",
	   "  </tr>",
	   " </table>",
	   "<input type='submit' name='action' value='Senden'>",
	   "</form>";
}

if ($action eq "Senden") {
	# write_log ("tellafriend","von $from an $mailad");
	`echo "Hallo,\n\nSchau dir mal die Webseite http://www.bildergallerie.de an.\n\nGruß $from" | mailx -s "Website Empfehlung" $mailad`;

	p2 "E-Mail an $mailad gesendet!<br>",
	   "<input type='submit' name='action' value='Schließen' onclick=\"window.close();\">";
}

p2 "</body>",
   "</html>";
   
