Uber newbie here. Have downloaded three different form scripts but none of them will actually send the email. Using yahoo small business standard hosting which says they support php. The form appears to work, it refers to the correct page, but no email. I don't know how to enable logs in the scripts so I don't have log files to share. Thanks in advance. Code follows:

form.php

$validReferrers = array('retas-school.com','www.retas-school.com','');

// Use the this array (or create new arrays with a different association) to replace
// setting fields in the form. Don't delete the 'default' array.

$formAction['default'] = array(
	'recipient' => 'admin@retas-school.com',
	'recipient_cc' => '',
	'recipient_bcc' => '',
	'subject' => 'LevelTen Formmail Test',
	'redirect' => 'http://www.retas-school.com/thankyou.html',
	'email' => '',
	'realname' => '',
	'required' => '',
	'format' => 'html',
	'sesrep_max_items' => '10',
);

ini_set("sendmail_from", "forms@retas-school.com"); 

// If set to 0, the form can set the email recipient. For security reasons you should
// set this variable to 1.

$disableFormRecipients = 1;

//////////////////////////////////////////////////////////////////////////////////////
//
// Start of code
// Don't edit below this line
//
//////////////////////////////////////////////////////////////////////////////////////

$pageHdr = "<html><head><style>td {font: x-small, verdana, arial, helvetica, sans-serif;} h1 {font-size: medium;} .err {color: #EE0000; font-weight: bold;}</style></head><body bgcolor=#FFFFFF><table width='500' align=center><tr><td>";
$pageFtr = "</td></tr>\n</body></html>";

$L10_LIBLoaded = 0;
if(file_exists("L10_LIB.php")) {
	include_once("L10_LIB.php");
	$L10_LIBLoaded = 1;
}

$HTTP_REF = getenv('HTTP_REFERER');
$a = preg_replace("/https?:\/\//","",$HTTP_REF);
$a = explode("/",$a);
$a = array_shift($a);

if(!in_array($a,$validReferrers)) {
	print "$pageHdr<p class=err>Invalid Referrer '$a'</p><p>Referrer does not have permission to access this LevelTen Formmail script.<p>For help on this issue, see <a href='http://www.leveltendesign.com/L10Apps/Fm/help_troubleshooting.php#invalidReferrer?hct=L10Fm-ErrMsg' target=_blank>LevelTen Formmail troubleshooting</a>$pageFtr";
	exit;
}

if(($_POST['form_action'] == '') || ($formAction[$_POST['form_action']]['recipient'] == '')) {
	$fAIndex = 'default';
} else {
	$fAIndex = $_POST['form_action'];
}

$recipient  = (!$disableFormRecipients && ($_POST['recipient'] != '')) ? $_POST['recipient'] : $formAction[$fAIndex]['recipient'];
$subject  = ($_POST['subject'] != '') ? $_POST['subject'] : $formAction[$fAIndex]['subject'];
$redirect = ($_POST['redirect'] != '') ? $_POST['redirect'] : $formAction[$fAIndex]['redirect'];
$email = ($_POST['email'] != '') ? $_POST['email'] : $formAction[$fAIndex]['email'];
$realname = ($_POST['realname'] != '') ? $_POST['realname'] : $formAction[$fAIndex]['realname'];
$recipient_cc  = (!$disableFormRecipients && ($_POST['recipient_cc'] != '')) ? $_POST['recipient_cc'] : $formAction[$fAIndex]['recipient_cc'];
$recipient_bcc  = (!$disableFormRecipients && ($_POST['recipient_bcc'] != '')) ? $_POST['recipient_bcc'] : $formAction[$fAIndex]['recipient_bcc'];
$format = ($_POST['format'] != '') ? $_POST['format'] : $formAction[$fAIndex]['format'];
$required  = ($_POST['required'] != '') ? $_POST['required'] : $formAction[$fAIndex]['required'];
$sesrep_max_items  = ($_POST['sesrep_max_items'] != '') ? $_POST['sesrep_max_items'] : $formAction[$fAIndex]['sesrep_max_items'];
$recipient_secured  = ($_POST['recipient_secured'] != '') ? $_POST['recipient_secured'] : $formAction[$fAIndex]['recipient_secured'];

$a = explode("@",$recipient);
$a = array_pop($a);
if(!in_array($a,$validReferrers)) {
	print "$pageHdr<p class=err>Invalid Recipient '$recipient'</p><p> Email address does not have permission to relay through this LevelTen Formmail script.<p>For help on this issue, see <a href='http://www.leveltendesign.com/L10Apps/Fm/help_troubleshooting.php#invalidReferrer?hct=L10Fm-ErrMsg' target=_blank>LevelTen Formmail troubleshooting</a>$pageFtr";
	exit;
}

$rccArray = explode(",",$recipient_cc);
$recipient_cc = '';
if($rccArray[0] != '') {
	foreach($rccArray as $rcc) {
		$a = explode("@",$rcc);
		$a = array_pop($a);
		if(in_array($a,$validReferrers)) {
			$recipient_cc .= "$rcc,";
		}
	}
}
$recipient_cc = substr($recipient_cc,0,-1);

$rbccArray = explode(",",$recipient_bcc);
$recipient_bcc = '';
if($rbccArray[0] != '') {
	foreach($rbccArray as $rbcc) {
		$a = explode("@",$rbcc);
		$a = array_pop($a);
		if(in_array($a,$validReferrers)) {
			$recipient_bcc .= "$rbcc,";
		}
	}
}
$recipient_bcc = substr($recipient_bcc,0,-1);

$a = explode(",",$required);
if($a[0] != '') {
	foreach($a as $req) {
		if($_POST[$req] == '') {
			print "$pageHdr<p class=err>Required Field '$req' is missing!</p><p> You must input a value for this field before submitting<p align=center><a href=\"".$HTTP_REFERER."\">back to form</a>$pageFtr";
			exit;
		}
	}
}


$htmlFormat = (strtolower(substr($format,0,1)) == 'h');

$msg = '';
if($htmlFormat) {
	$msg = "<html><head><style>td {font: x-small, verdana, arial, helvetica, sans-serif;} .fldname {font-weight:bold;font-size:x-small;} .flddata {font-size:x-small;} .tblhdr { font-size:x-small;font-weight:bold;color:#FFFFFF;background-color=#000088}</style></head><body>\n";
	$msg .= "<table border=0 cellspacing=0 cellpadding=0 width=640>\n";
	$msg .= "<tr><td colspan=3 class='tblhdr'>Form Data</td></tr>\n";
} else {
	$msg = "Form data\n\n";
}

$bl0 = '';
$bl1 = '';
$ld = ' ';
$el = "\n\n";

$creditStrAdd = '';

if($htmlFormat) {
	$bl0 = '<tr bgcolor=#E8E8FF><td class="fldname" valign=top>';
	$bl1 = '<tr bgcolor=#FFFFFF><td class="fldname" valign=top>';
	$ld = '</td><td> &nbsp; </td><td width=80% class="flddata">';
	$el = "</td></tr>\n";
}
$i = 0;
foreach($_POST as $k => $v) {
	if($htmlFormat) {
		$v = str_replace("\n","<br>\n",$v);
	}
	if($i) {
		$msg .= "$bl0$k:$ld$v$el";
	} else {
		$msg .= "$bl1$k:$ld$v$el";
	}
	$i = !$i;
}

if(file_exists("L10HC_API.php")) {
	include("L10HC_API.php");
	$vID = getVID();
	if($htmlFormat) {
		$msg .= "<tr><td colspan=3><br>&nbsp;<br></td></tr>\n<tr><td colspan=3 border=1>";
		$creditStrAdd = ' &amp; LevelTen Hit Counter';
	} else {
		$msg .= "\n\n";
		$creditStrAdd = ' & LevelTen Hit Counter';
	}
	$msg .= getSessions($vID,$max_sessions,$recipient_secured,$htmlFormat+1);
	if($htmlFormat) {
		$msg .= "</td></tr>\n";
	} else {

	}
}

if($htmlFormat) {
	$msg .= "<tr><td colspan=3>&nbsp;</td></tr><tr><td colspan=3 align=center>Generated by<br>LevelTen Formmail$creditStrAdd<td></tr></table></body></html>\n";
} else {
	$msg .= "\n\nGenerated by LevelTen Formmail$creditStrAdd\n";
}

$extraHeaders = "";
if($email != '') { $extraHeaders .= "From: \"".addslashes($realname)."\" <".$email.">\r\n"; }
if($realname != '') { $extraHeaders .= "Reply-To: $email\r\n"; }
if($htmlFormat == 'h') { $extraHeaders .= "Content-type: text/html\r\n"; }
if($recipient_cc != '') { $extraHeaders .= "Cc: $recipient_cc\r\n"; }
if($recipient_bcc != '') { $extraHeaders .= "Bcc: $recipient_bcc\r\n"; }

$success = 1;
$success = mail($recipient,$subject,$msg,$extraHeaders);

if(!$success && $L10_LIBLoaded) {
	log_event("Unsuccesful Email Attempt: $recipient");
}

//print "mail($recipient,$subject,$msg,$extraHeaders)";
//print "$msg";

header("Location: $redirect");
?>

sample_form.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- <?php echo date("n/d/y h:i" ,time()); ?> -->
<html>
<head>
<title>LevelTen Formmail Sample Form</title>
<script language="JavaScript" type="text/javascript">

function submitForm() {
if(document.theForm.realname.value.length < 1) {
alert("Please enter your name.");
document.theForm.realname.focus();
return;
} else if(document.theForm.email.value.length < 4) {
alert("Please enter a valid e-mail address.");
document.theForm.email.focus();
return;
}
document.theForm.submit();
}
</script>

<style>
td {font-family: arial,helvetica,sans-serif;}
</style>

</head>
<body>
<form name="theForm" action="L10FmX.php" METHOD="POST">
<input type="hidden" name="required" value="email,realname">

<table cellpadding="0" cellspacing="0" border="0" align=center>
<tr><td colspan=2 align=center><p><b>LevelTen Formmail Sample Form</b><p></td></tr>
<tr><td>Sender's E-Mail:*</td><td><input type="Text" name="email" size=30></td></tr>
<tr><td>Sender's Name:*</td><td><input type="Text" name="realname" size=30></td></tr>
<tr><td colspan=2>
Message:<br>
<textarea name=message cols=40 rows=10></textarea><p>
</td></tr>
<tr><td colspan=2 align=center><input type="Button" name="submitBtn" value="Test LevelTen Formmail" onClick="submitForm();"></td></tr>
</table>
</form>
</body>
</html>

Recommended Answers

All 5 Replies

UPDATE:

I got the script to work from:

PHP Tutorial: Writing Your First PHP Script: Feedback Form Script by Christopher Heng, thesitewizard.com,

so at least I know that yahoo is working properly.

Sorry for failing to use the BB tags on my code earlier, will not make that mistake again. Thanks, J.

OK, I used the suggested code change. This is the form.php code:

$validReferrers = array('retas-school.com','www.retas-school.com','');

// Use the this array (or create new arrays with a different association) to replace
// setting fields in the form. Don't delete the 'default' array.

$formAction['default'] = array(
    'recipient' => 'admin@retas-school.com',
    'recipient_cc' => '',
    'recipient_bcc' => '',
    'subject' => 'LevelTen Formmail Test',
    'redirect' => 'http://www.retas-school.com/thankyou.html',
    'email' => '',
    'realname' => '',
    'required' => '',
    'format' => 'html',
    'sesrep_max_items' => '10',
);

ini_set("sendmail_from", "forms@retas-school.com");

// If set to 0, the form can set the email recipient. For security reasons you should
// set this variable to 1.

$disableFormRecipients = 1;

//////////////////////////////////////////////////////////////////////////////////////
//
// Start of code
// Don't edit below this line
//
//////////////////////////////////////////////////////////////////////////////////////

$pageHdr = "<html><head><style>td {font: x-small, verdana, arial, helvetica, sans-serif;} h1 {font-size: medium;} .err {color: #EE0000; font-weight: bold;}</style></head><body bgcolor=#FFFFFF><table width='500' align=center><tr><td>";
$pageFtr = "</td></tr>\n</body></html>";

$L10_LIBLoaded = 0;
if(file_exists("L10_LIB.php")) {
    include_once("L10_LIB.php");
    $L10_LIBLoaded = 1;
}

$HTTP_REF = getenv('HTTP_REFERER');
$a = preg_replace("/https?:\/\//","",$HTTP_REF);
$a = explode("/",$a);
$a = array_shift($a);

if(!in_array($a,$validReferrers)) {
    print "$pageHdr<p class=err>Invalid Referrer '$a'</p><p>Referrer does not have permission to access this LevelTen Formmail script.<p>For help on this issue, see <a href='http://www.leveltendesign.com/L10Apps/Fm/help_troubleshooting.php#invalidReferrer?hct=L10Fm-ErrMsg' target=_blank>LevelTen Formmail troubleshooting</a>$pageFtr";
    exit;
}

if(($_POST['form_action'] == '') || ($formAction[$_POST['form_action']]['recipient'] == '')) {
    $fAIndex = 'default';
} else {
    $fAIndex = $_POST['form_action'];
}

$recipient  = (!$disableFormRecipients && ($_POST['recipient'] != '')) ? $_POST['recipient'] : $formAction[$fAIndex]['recipient'];
$subject  = ($_POST['subject'] != '') ? $_POST['subject'] : $formAction[$fAIndex]['subject'];
$redirect = ($_POST['redirect'] != '') ? $_POST['redirect'] : $formAction[$fAIndex]['redirect'];
$email = ($_POST['email'] != '') ? $_POST['email'] : $formAction[$fAIndex]['email'];
$realname = ($_POST['realname'] != '') ? $_POST['realname'] : $formAction[$fAIndex]['realname'];
$recipient_cc  = (!$disableFormRecipients && ($_POST['recipient_cc'] != '')) ? $_POST['recipient_cc'] : $formAction[$fAIndex]['recipient_cc'];
$recipient_bcc  = (!$disableFormRecipients && ($_POST['recipient_bcc'] != '')) ? $_POST['recipient_bcc'] : $formAction[$fAIndex]['recipient_bcc'];
$format = ($_POST['format'] != '') ? $_POST['format'] : $formAction[$fAIndex]['format'];
$required  = ($_POST['required'] != '') ? $_POST['required'] : $formAction[$fAIndex]['required'];
$sesrep_max_items  = ($_POST['sesrep_max_items'] != '') ? $_POST['sesrep_max_items'] : $formAction[$fAIndex]['sesrep_max_items'];
$recipient_secured  = ($_POST['recipient_secured'] != '') ? $_POST['recipient_secured'] : $formAction[$fAIndex]['recipient_secured'];

$a = explode("@",$recipient);
$a = array_pop($a);
if(!in_array($a,$validReferrers)) {
    print "$pageHdr<p class=err>Invalid Recipient '$recipient'</p><p> Email address does not have permission to relay through this LevelTen Formmail script.<p>For help on this issue, see <a href='http://www.leveltendesign.com/L10Apps/Fm/help_troubleshooting.php#invalidReferrer?hct=L10Fm-ErrMsg' target=_blank>LevelTen Formmail troubleshooting</a>$pageFtr";
    exit;
}

$rccArray = explode(",",$recipient_cc);
$recipient_cc = '';
if($rccArray[0] != '') {
    foreach($rccArray as $rcc) {
        $a = explode("@",$rcc);
        $a = array_pop($a);
        if(in_array($a,$validReferrers)) {
            $recipient_cc .= "$rcc,";
        }
    }
}
$recipient_cc = substr($recipient_cc,0,-1);

$rbccArray = explode(",",$recipient_bcc);
$recipient_bcc = '';
if($rbccArray[0] != '') {
    foreach($rbccArray as $rbcc) {
        $a = explode("@",$rbcc);
        $a = array_pop($a);
        if(in_array($a,$validReferrers)) {
            $recipient_bcc .= "$rbcc,";
        }
    }
}
$recipient_bcc = substr($recipient_bcc,0,-1);

$a = explode(",",$required);
if($a[0] != '') {
    foreach($a as $req) {
        if($_POST[$req] == '') {
            print "$pageHdr<p class=err>Required Field '$req' is missing!</p><p> You must input a value for this field before submitting<p align=center><a href=\"".$HTTP_REFERER."\">back to form</a>$pageFtr";
            exit;
        }
    }
}


$htmlFormat = (strtolower(substr($format,0,1)) == 'h');

$msg = '';
if($htmlFormat) {
    $msg = "<html><head><style>td {font: x-small, verdana, arial, helvetica, sans-serif;} .fldname {font-weight:bold;font-size:x-small;} .flddata {font-size:x-small;} .tblhdr { font-size:x-small;font-weight:bold;color:#FFFFFF;background-color=#000088}</style></head><body>\n";
    $msg .= "<table border=0 cellspacing=0 cellpadding=0 width=640>\n";
    $msg .= "<tr><td colspan=3 class='tblhdr'>Form Data</td></tr>\n";
} else {
    $msg = "Form data\n\n";
}

$bl0 = '';
$bl1 = '';
$ld = ' ';
$el = "\n\n";

$creditStrAdd = '';

if($htmlFormat) {
    $bl0 = '<tr bgcolor=#E8E8FF><td class="fldname" valign=top>';
    $bl1 = '<tr bgcolor=#FFFFFF><td class="fldname" valign=top>';
    $ld = '</td><td> &nbsp; </td><td width=80% class="flddata">';
    $el = "</td></tr>\n";
}
$i = 0;
foreach($_POST as $k => $v) {
    if($htmlFormat) {
        $v = str_replace("\n","<br>\n",$v);
    }
    if($i) {
        $msg .= "$bl0$k:$ld$v$el";
    } else {
        $msg .= "$bl1$k:$ld$v$el";
    }
    $i = !$i;
}

if(file_exists("L10HC_API.php")) {
    include("L10HC_API.php");
    $vID = getVID();
    if($htmlFormat) {
        $msg .= "<tr><td colspan=3><br>&nbsp;<br></td></tr>\n<tr><td colspan=3 border=1>";
        $creditStrAdd = ' &amp; LevelTen Hit Counter';
    } else {
        $msg .= "\n\n";
        $creditStrAdd = ' & LevelTen Hit Counter';
    }
    $msg .= getSessions($vID,$max_sessions,$recipient_secured,$htmlFormat+1);
    if($htmlFormat) {
        $msg .= "</td></tr>\n";
    } else {

    }
}

if($htmlFormat) {
    $msg .= "<tr><td colspan=3>&nbsp;</td></tr><tr><td colspan=3 align=center>Generated by<br>LevelTen Formmail$creditStrAdd<td></tr></table></body></html>\n";
} else {
    $msg .= "\n\nGenerated by LevelTen Formmail$creditStrAdd\n";
}

$extraHeaders = "";
if($email != '') { $extraHeaders .= "From: \"".addslashes($realname)."\" <".$email.">\r\n"; }
if($realname != '') { $extraHeaders .= "Reply-To: $email\r\n"; }
if($htmlFormat == 'h') { $extraHeaders .= "Content-type: text/html\r\n"; }
if($recipient_cc != '') { $extraHeaders .= "Cc: $recipient_cc\r\n"; }
if($recipient_bcc != '') { $extraHeaders .= "Bcc: $recipient_bcc\r\n"; }

$success = 1;
$success = mail($recipient,$subject,$msg,$extraHeaders);

if(!$success && $L10_LIBLoaded) {
    log_event("Unsuccesful Email Attempt: $recipient");
}

//print "mail($recipient,$subject,$msg,$extraHeaders)";
//print "$msg";

header("Location: $redirect");
?>

This is the sample_form.html code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!-- <?php echo date("n/d/y h:i" ,time()); ?> -->
  <title>LevelTen Formmail Sample
Form</title>
  <script language="JavaScript" type="text/javascript">

function submitForm() {
if(document.theForm.realname.value.length < 1) {
alert("Please enter your name.");
document.theForm.realname.focus();
return;
} else if(document.theForm.email.value.length < 4) {
alert("Please enter a valid e-mail address.");
document.theForm.email.focus();
return;
}
document.theForm.submit();
}
  </script>
  <style>
td {font-family: arial,helvetica,sans-serif;}
  </style>
</head>
<body>
<form name="theForm" action="test_script.php" method="post"> <input
 name="required" value="email,realname" type="hidden">
  <table align="center" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td colspan="2" align="center">
        <p><b>LevelTen
Formmail Sample Form</b></p>
        <p></p>
        </td>
      </tr>
      <tr>
        <td>Sender's E-Mail:*</td>
        <td><input name="email" size="30" type="text"></td>
      </tr>
      <tr>
        <td>Sender's Name:*</td>
        <td><input name="realname" size="30" type="text"></td>
      </tr>
      <tr>
        <td colspan="2">
Message:<br>
        <textarea name="message" cols="40" rows="10"></textarea>
        <p> </p>
        </td>
      </tr>
      <tr>
        <td colspan="2" align="center"><input name="submitBtn"
 value="Test LevelTen Formmail" onclick="submitForm();" type="button"></td>
      </tr>
    </tbody>
  </table>
</form>
</body>
</html>

This returned this error page:

$validReferrers = array('retas-school.com','www.retas-school.com',''); // Use the this array (or create new arrays with a different association) to replace // setting fields in the form. Don't delete the 'default' array. $formAction = array( 'recipient' => 'admin@retas-school.com', 'recipient_cc' => '', 'recipient_bcc' => '', 'subject' => 'LevelTen Formmail Test', 'redirect' => 'http://www.retas-school.com/thankyou.html', 'email' => '', 'realname' => '', 'required' => '', 'format' => 'html', 'sesrep_max_items' => '10', ); ini_set("sendmail_from", "forms@retas-school.com"); // If set to 0, the form can set the email recipient. For security reasons you should // set this variable to 1. $disableFormRecipients = 1; ////////////////////////////////////////////////////////////////////////////////////// // // Start of code // Don't edit below this line // ////////////////////////////////////////////////////////////////////////////////////// $pageHdr = "\n"; $L10_LIBLoaded = 0; if(file_exists("L10_LIB.php")) { include_once("L10_LIB.php"); $L10_LIBLoaded = 1; } $HTTP_REF = getenv('HTTP_REFERER'); $a = preg_replace("/https?:\/\//","",$HTTP_REF); $a = explode("/",$a); $a = array_shift($a); if(!in_array($a,$validReferrers)) { print "$pageHdr

Invalid Referrer '$a'

Referrer does not have permission to access this LevelTen Formmail script.

For help on this issue, see LevelTen Formmail troubleshooting$pageFtr"; exit; } if(($_POST == '') || ($formAction[$_POST] == '')) { $fAIndex = 'default'; } else { $fAIndex = $_POST; } $recipient = (!$disableFormRecipients && ($_POST != '')) ? $_POST : $formAction[$fAIndex]; $subject = ($_POST != '') ? $_POST : $formAction[$fAIndex]; $redirect = ($_POST != '') ? $_POST : $formAction[$fAIndex]; $email = ($_POST != '') ? $_POST : $formAction[$fAIndex]; $realname = ($_POST != '') ? $_POST : $formAction[$fAIndex]; $recipient_cc = (!$disableFormRecipients && ($_POST != '')) ? $_POST : $formAction[$fAIndex]; $recipient_bcc = (!$disableFormRecipients && ($_POST != '')) ? $_POST : $formAction[$fAIndex]; $format = ($_POST != '') ? $_POST : $formAction[$fAIndex]; $required = ($_POST != '') ? $_POST : $formAction[$fAIndex]; $sesrep_max_items = ($_POST != '') ? $_POST : $formAction[$fAIndex]; $recipient_secured = ($_POST != '') ? $_POST : $formAction[$fAIndex]; $a = explode("@",$recipient); $a = array_pop($a); if(!in_array($a,$validReferrers)) { print "$pageHdr

Invalid Recipient '$recipient'

Email address does not have permission to relay through this LevelTen Formmail script.

For help on this issue, see LevelTen Formmail troubleshooting$pageFtr"; exit; } $rccArray = explode(",",$recipient_cc); $recipient_cc = ''; if($rccArray[0] != '') { foreach($rccArray as $rcc) { $a = explode("@",$rcc); $a = array_pop($a); if(in_array($a,$validReferrers)) { $recipient_cc .= "$rcc,"; } } } $recipient_cc = substr($recipient_cc,0,-1); $rbccArray = explode(",",$recipient_bcc); $recipient_bcc = ''; if($rbccArray[0] != '') { foreach($rbccArray as $rbcc) { $a = explode("@",$rbcc); $a = array_pop($a); if(in_array($a,$validReferrers)) { $recipient_bcc .= "$rbcc,"; } } } $recipient_bcc = substr($recipient_bcc,0,-1); $a = explode(",",$required); if($a[0] != '') { foreach($a as $req) { if($_POST[$req] == '') { print "$pageHdr

Required Field '$req' is missing!

You must input a value for this field before submitting
"; $pageFtr = "

back to form$pageFtr"; exit; } } } $htmlFormat = (strtolower(substr($format,0,1)) == 'h'); $msg = ''; if($htmlFormat) { $msg = "\n"; $msg .= "
\n"; $msg .= "\n"; } else { $msg = "Form data\n\n"; } $bl0 = ''; $bl1 = ''; $ld = ' '; $el = "\n\n"; $creditStrAdd = ''; if($htmlFormat) { $bl0 = '\n"; } $i = 0; foreach($_POST as $k => $v) { if($htmlFormat) { $v = str_replace("\n","
\n",$v); } if($i) { $msg .= "$bl0$k:$ld$v$el"; } else { $msg .= "$bl1$k:$ld$v$el"; } $i = !$i; } if(file_exists("L10HC_API.php")) { include("L10HC_API.php"); $vID = getVID(); if($htmlFormat) { $msg .= "\n\n"; } else { } } if($htmlFormat) { $msg .= "
Form Data
'; $bl1 = '
'; $ld = ' '; $el = "


"; $creditStrAdd = ' & LevelTen Hit Counter'; } else { $msg .= "\n\n"; $creditStrAdd = ' & LevelTen Hit Counter'; } $msg .= getSessions($vID,$max_sessions,$recipient_secured,$htmlFormat+1); if($htmlFormat) { $msg .= "

Generated by
LevelTen Formmail$creditStrAdd
\n"; } else { $msg .= "\n\nGenerated by LevelTen Formmail$creditStrAdd\n"; } $extraHeaders = ""; if($email != '') { $extraHeaders .= "From: \"".addslashes($realname)."\" <".$email.">\r\n"; } if($realname != '') { $extraHeaders .= "Reply-To: $email\r\n"; } if($htmlFormat == 'h') { $extraHeaders .= "Content-type: text/html\r\n"; } if($recipient_cc != '') { $extraHeaders .= "Cc: $recipient_cc\r\n"; } if($recipient_bcc != '') { $extraHeaders .= "Bcc: $recipient_bcc\r\n"; } $success = 1; $success = mail($recipient,$subject,$msg,$extraHeaders); if(!$success && $L10_LIBLoaded) { log_event("Unsuccesful Email Attempt: $recipient"); } //print "mail($recipient,$subject,$msg,$extraHeaders)"; //print "$msg"; header("Location: $redirect"); ?>

Now I am more confused than ever. Should I give up?

Jon,

You have created a monster. For example you rely on javascript and I for one couldn't use your form. XP rejects that.

What are you trying to accomplish?

I use both formmail and mail() scripts and they both are routine.

State your goals and I'll try to help. Don't quit, just take a deep breath.

Andy

I'm trying to create a generic form that will send to my admin email account. I have a few different forms that will use the generic template, once I figure out how to make it work. Thanks.

Jon,
See if this helps:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Volunteer Opportunities Form</title>
    <meta name="description" content="Volunteer Opportunities Enrolment Form  " />


    <link rel="stylesheet"
          href="first.css"
          type="text/css" />
<style type="text/css">
<!--
div#main    {
    padding: 0px 15px 0px 15px;
    }
div#main dt {margin-left: 25px;
    text-align: left;
    font:90% "Arial black", san-serif;
    border-top: 0px solid Green;
    margin-top: 20px;
    }
div#main dd  {
    margin-left: 100px;

    text-align: left;
    font:  bold 80%/130% "verdana", san-serif;
    line-height: 150%;
}
div#main li  {
    margin-left: 100px;
    text-align: left;
    font:  bold 80%/130% "verdana", san-serif;
    line-height: 150%;
}
.label  {
    text-align: right;
    margin-right: 150px;
}
.ans    {
    text-align: left;
    margin-left: 160px;
}
.button {
    width: 200;
    text-align: center;
}

-->
</style>
</head>

<body>
    <div id="container">
        <div id="menu">
           <?php
        include("menu.inc");
    ?>
        </div><!--end div menu-->

        <div id="namipa">
            <div id="logo">
                <img src="images/logo.gif"
                     alt="NAMI PA Logo"
                     width="115"
                     height="115" />
            </div><!--end div logo-->

            <div id="nami">
                <h1>Name here</h1>

                <h2><em>surname here</em></h2>
                <hr />

                <h2>sursurname here</h2>

                <h3>address</h3><br />

                <h3>phone and fax</h3>
            </div><!--end div nami-->
        </div><!--end div namipa-->

        <div id="main">


<h2>Volunteer Enrolment Form</h2>

<form action="Joh, this is the address to formmail provided by your ISP"
          method="post"
          enctype="application/x-www-form-urlencoded"
          name="Survey">
        <input type="hidden"
              name="recipient"
              value="your admin email address here" /> 
    <input type="hidden"
              name="subject"
              value="Volunteer_Enrolment" /> 
    <input type="hidden"
              name="redirect"
              value="acknowledgement.php" />
<table summary="Enrolment Information">
<tr><td class="label">First Name</td><td class="ans"><input type="text" size="60" name="Firstname" /></td></tr>
<tr><td class="label">Last Name</td><td class="ans"><input type="text" size="60" name="Lastname" /></td></tr>
<tr><td class="label">Address</td><td class="ans"><input type="text" size="60" name="Address" /></td></tr>
<tr><td class="label">City</td><td class="ans"><input type="text" size="60" name="City" /></td></tr>
<tr><td class="label">State</td><td class="ans"><input type="text" size="10" name="State" /> Zip <input type="text" size="10" name="Zip" /></td></tr>
<tr><td class="label">Home Phone</td><td class="ans"><input type="text" size="60" name="Home_Phone" /></td></tr>
<tr><td class="label">Email</td><td class="ans"><input type="text" size="60" name="Email" /></td></tr>
<tr><td class="label">Days/Hours available</td><td class="ans"><textarea rows="3" cols="40" name="When_Available"></textarea></td></tr>
<tr><td class="label">Volunteer Interests:</td><td class="ans">
<select name="Volunteer_Interests" multiple size="5">
<option value="Clerical">Clerical</option>
<option value="Hospital">Hospital</option>
<option value="Speaker_Outreach">Speakers Bureau & Outreach</option>
<option value="Special_Grants">Grant Research & Writing</option>
<option value="Special_Legislators">Legislators</option>
<option value="Special_Media">Media/Anti-Stigma</option>
<option value="Special_Events">Event Coordinator</option>
<option value="Library">Library Assistant</option>
<option value="Vol_Services">Volunteer Services</option>
<option value="Peer_Group_Teacher">Teacher, Group Facilitator/Peer-to-Peer Course</option>
<option value="Peer_Group_Leader">Leader, Peer-to-Peer Group</option>
<option value="Maintenance">Maintenance</option>
<option value="Fundraising">Fundraising</option>
<option value="Courts">Courts</option>
</select></td></tr></table>
<table summary="Submit & Reset" style="width:100%">
<col width="48%" />
<col width="1%" />
<col width="49%" />
<tbody>
<tr><td class="button"><input type="submit" value="submit" name="submit" /></td><td class="button"> </td><td class="button"><input type="reset" value="reset" name="reset" /></td></tr>
</tbody>
</table>
</form>            
            <hr />
</div><!--End of main-->
            <p class="center">
            <a href="mailto:webmaster goes here">Web
            Administrator</a></p>

        <hr />

    </div><!--End of container-->
    </body>
</html>
<!--validated W3C 9/Feb/2005 9:36-->

Andy

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.