Location: PHPKode > scripts > PHP Form to Mail > formmail_light/www/fm_setup.php
<?php
// Copyright 2009, Robert Rook
// Released under the terms of the
// ABD Free Source Code Licence.

if(file_exists("./formmail.php") || !file_exists("./fm_config.php")) {
	echo "formmail.php already exists, or fm_config is not present ";
	echo "in this folder.<br>\n";
	die("Setup cannot continue.");
}

if(isset($_POST['email'])) {
	// All information is copied exactly, except
	// addslashes() is called to escape certain
	// characters.
	$_POST['email'] = addslashes($_POST['email']);
	$_POST['subject'] = addslashes($_POST['subject']);
	$_POST['from'] = addslashes($_POST['from']);
	$_POST['site'] = addslashes($_POST['site']);
	$config_head = "";
	$config_head.= "\$config['to'] = \"{$_POST['email']}\";\n";
	$config_head.= "\$config['subject'] = \"{$_POST['subject']}\";\n";
	$config_head.= "\$config['from'] = \"{$_POST['from']}\";\n";
	$config_head.= "\$config['site'] = \"{$_POST['site']}\";\n";
	$fp = fopen("./fm_config.php","r");
	$fout = fopen("./formmail.php","w");

	while($line = fgets($fp)) {
		if(trim($line)=="die(\"CONFIG\");") { }
		else if(trim($line)=="//CONFIG") { fwrite($fout,$config_head); }
		else { fwrite($fout,$line); }
	}

	fclose($fp);
	fclose($fout);

	echo "<h1>Config completed</h1>\n";
	echo "<p>Providing all went well, formmail.php should now exist\n";
	echo "and be configured for your server.</p>\n";
	die();
}
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>

<title> AdvanceByDesign Form to Mail (Light) </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
body {
	padding:10px;
	margin:0;
	background-color:#CCC;
	font-family:Verdana,Helvetica,Arial,sans-serif;
	font-size:100%;
	color:#777;
}
h1 {
	font-size:1.6em;
	padding:0;
	margin:0;
	clear:none;
}
h2 {
	font-size:1.4em;
	padding:0;
	margin:0;
	clear:none;
	color:#AAA;
}
.mail_box {
	width:430px;
	padding:10px;
	background-color:#FFF;
	font-size:0.7em;
	border:1px solid;
	border-color:#EEE #333 #333 #EEE;
}
.row {
	padding:5px;
	clear:both;
}
.row input {
	width:40%;
	float:right;
	border:1px solid #AAA;
	color:#777;
}
.row textarea {
	width:60%;
	float:right;
	border:1px solid #AAA;
	color:#777;
}
.row .submitbutton {
	background-color:#EEE;
	color:#000;
	border:1px solid;
	border-color:#EEE #333 #333 #EEE;
}
.error_box {
	margin:2px;
	padding:5px;
	clear:both;
	border:1px solid #F99;
	background-color:#FEE;
	color:#900;
	display:none;
}
.header_box {
	padding:6px;
	font-size:100%;
	background-color:#FFE;
	border:1px solid;
	border-color:#AAA #EEE #EEE #AAA;
}
.footer_box {
	clear:both;
	padding:10px;
	text-align:center;
	font-size:0.8em;
}
b {
	color:#F00;
}
</style>

</head>
<body>

<div class="mail_box">

<div class="header_box">
<h1>Configure FtM (Light)</h1>
<h2>Form to Mail Light script</h2>

<p>Configure your Form to Mail Light script using the
form below.  If your server does not allow PHP Write
access to files, you must manually configure the
<i>formmail.php</i> file.</p>

<p>Enter information exactly as you want it to appear
in the form.</p>
</div>

<form method="post" action="fm_setup.php">
<div class="row"><input type="text" name="email">Your email address<br>
<small>(Where the form results will be mailed to)</small></div>
<div class="row"><input type="text" name="subject" maxlength="60" value="ABD FormMail [_DATE_]">Mail subject<br>
<small>(The subject for letters recieved via the form)</small></div>
<div class="row"><input type="text" name="from">From address<br>
<small>(The email address letters sent via the form will appear to be
from)</small></div>
<div class="row"><input type="text" name="site">Site name<br>
<small>(The site name/address letters will be reported as being sent
from)</small></div>
<div class="row"><input type="submit" class="submitbutton" value="Setup..."></div>
</form>

</div>

</body>
</html>
Return current item: PHP Form to Mail