CForm::Mail( int RESULT_ID, int TEMPLATE_ID="" );
This method is used to send the result via the e-mail using the mail template .
| Parameter | Description |
|---|---|
| RESULT_ID | Result ID. |
| TEMPLATE_ID | Mail template ID. If omitted, the default template specified for this form is used. |
The below example shows the sample file "form_fill.php" displaying the form.
<?
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
if (CModule::IncludeModule("form"))
{
if (intval($WEB_FORM_ID)>0)
$z = <b>CForm::GetByID</b>($WEB_FORM_ID);
else
$z = CForm::GetBySID($WEB_FORM_NAME);
if (!($zr=$z->Fetch()))
{
$FORM_EXIST = "N";
$strError .= "Invalid form ID.<br>";
}
else
{
$FORM_EXIST = "Y";
$WEB_FORM_ID = $zr["ID"];
$WEB_FORM_NAME = $zr["VARNAME"];
if ($REQUEST_METHOD=="POST" &&
intval($WEB_FORM_ID)>0 &&
strlen($web_form_submit)>0)
{
$arrVALUES = $HTTP_POST_VARS;
$error = CForm::Check($WEB_FORM_ID);
if (strlen($error)<=0)
{
if ($RESULT_ID = CFormResult::Add($WEB_FORM_ID))
{
$arr = CFormResult::GetDataByID($RESULT_ID, array("VS_PHOTO"));
$PHOTO_EXIST = (intval($arr["VS_PHOTO"][0]["USER_FILE_ID"])>0) ? "Y" : "N";
CFormResult::SetField($RESULT_ID, "VS_PHOTO_EXIST", $PHOTO_EXIST);
CForm::SetEvent($RESULT_ID);
CForm::Mail($RESULT_ID);
LocalRedirect("index.php?WEB_FORM_NAME=".$WEB_FORM_NAME. "&strNote=".urlencode("Information saved"));
}
}
else
$strError .= $error;
}
}
}
if (strlen($APPLICATION->GetTitle()) <= 0)
$APPLICATION->SetTitle("Visitor survey");
require_once ($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_after.php");
echo ShowNote($strNote);
echo ShowError($strError);
?><?
if (CModule::IncludeModule("form"))
CForm::Show($WEB_FORM_NAME, $arrVALUES);
require_once ($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog.php");
?>
| © 2001-2005 Bitrix | Bitrix Site Manager - Content Management & Portal Solutions |