- Поисковые системы
- Практика оптимизации
- Трафик для сайтов
- Монетизация сайтов
- Сайтостроение
- Социальный Маркетинг
- Общение профессионалов
- Биржа и продажа
- Финансовые объявления
- Работа на постоянной основе
- Сайты - покупка, продажа
- Соцсети: страницы, группы, приложения
- Сайты без доменов
- Трафик, тизерная и баннерная реклама
- Продажа, оценка, регистрация доменов
- Ссылки - обмен, покупка, продажа
- Программы и скрипты
- Размещение статей
- Инфопродукты
- Прочие цифровые товары
- Работа и услуги для вебмастера
- Оптимизация, продвижение и аудит
- Ведение рекламных кампаний
- Услуги в области SMM
- Программирование
- Администрирование серверов и сайтов
- Прокси, ВПН, анонимайзеры, IP
- Платное обучение, вебинары
- Регистрация в каталогах
- Копирайтинг, переводы
- Дизайн
- Usability: консультации и аудит
- Изготовление сайтов
- Наполнение сайтов
- Прочие услуги
- Не про работу
Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий
Всем привет!
На одной из страниц сайта (Joomla) есть форма отправки письма на почту. После заполнения формы на почту приходит пустое письмо. Помогите, плиз, кто может решить данную проблему. Вот код php файла самой формы:
++++++++++++++++++++++++++++++++++++++++++++
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
$showform=true;
$captcha_type = $params->get('captcha_type');
$form_width = $params->get('form_width','400px');
$unique = md5($params->get('form_labels').$params->get('form_types').$params->get('form_validations'));
$unique = $unique . $params->get('mod_pref',$unique);
$form_labels = explode("\n",$params->get('form_labels'));
$total_elements = count($form_labels);
$form_types = explode("\n",$params->get('form_types'));
$form_validations = explode("\n",$params->get('form_validations'));
$form_elements = array();
$hidden = array();
$validator = "";
?>
<div style="width:<?php echo $form_width; ?>;">
<?php
##################################
## PROCESS FORM ##
##################################
if( $captcha_type == 1){
require_once(dirname(__FILE__).DS.'recaptchalib.php');
$publickey = $params->get('public_key');
$privatekey = $params->get('private_key');
# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;
}
if(!empty($_POST["submit".$unique])):
if ($_POST["recaptcha_response_field"]) {
$resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"],$_POST["recaptcha_response_field"]);
}
if(($captcha_type == 0) && strtolower($_SESSION['jxforms_securitycode']) != strtolower($_POST['jxforms_securitycode'])):
echo ("<div align='center' style='background-color:#F00; color:#FFF; width:90%; border:#000 thin double;'>Incorrect security code <br />You typed ".$_POST['jxforms_securitycode'].' instead of '.$_SESSION['jxforms_securitycode'].'.<br />Your message was not submitted!</div>');
$_SESSION['jxforms_securitycode'] = "typing a new message!";
elseif(( $captcha_type == 1) && !($resp->is_valid)):
$error = $resp->error;
echo ("<div align='center' style='background-color:#F00; color:#FFF; width:90%; border:#000 thin double;'>Incorrect security code .<br />Your message was not sent!</div>");
else:
$_SESSION['jxforms_securitycode'] = "reloading this page!";
######################################################
## Function to get ip address of a client ##
######################################################
function getIpAddress() {
return (empty($_SERVER['HTTP_CLIENT_IP'])?(empty($_SERVER['HTTP_X_FORWARDED_FOR'])? $_SERVER['REMOTE_ADDR']:$_SERVER['HTTP_X_FORWARDED_FOR']):$_SERVER['HTTP_CLIENT_IP']);
}
#####################################################
$mailer =& JFactory::getMailer();
$body = '<style type="text/css">'.$params->get('form_css').'</style>';
$body .= '<table width="100%" border="0" cellspacing="5" cellpadding="0">';
$hiddenField = $_POST['hiddenField'];
$hiddenField = unserialize($hiddenField);
$attached_files = array();
$body .= "</table>";
$sender = array($params->get('sender'),$params->get('sender'));
$mailer->setSender($sender);
$mailer->addRecipient($params->get('recipient'));
$mailer->setSubject($params->get('subject'));
$mailer->isHTML(true);
$mailer->setBody($body);
if(!$mailer->Send()) {
echo "<div align='center' style='background-color:#F00; color:#FFF; width:90%; border:#000 thin double;'>Message Error: " . $mail->ErrorInfo.'</div>';
$showform=true;
} else {
echo "<div align='center' style='background-color:#F00; color:#FFF; width:90%; border:#000 thin double;'>".$params->get('success_message', 'Your message has been sent successfully! Thank you.')."</div>";
$showform=false;
}
foreach($attached_files as $value){
unlink($value);
}
endif;
endif;
##################################################################
## Create the form elements and store ##
## them in $form_elements to echo later ##
##################################################################
for($i=0; $i < $total_elements; $i++){
//get the admin specified type or set a default
$type = (empty($form_types[$i])) ? "text" : strtolower($form_types[$i]);
//get whether admin specified this as a required field or set as optional
$form_validations[$i] = (empty($form_validations[$i]))? "optional" : strtolower($form_validations[$i]);
//Save the admin specified labels against the form element name. Will be used to process the form
$hidden[$form_labels[$i]] = ($type == 'file') ? 'file'.$unique.$i : 'element'.$unique.$i;
//Check and effect required fields
if($form_validations[$i] == "required" && $type == 'file') $validator .= 'frmvalidator.addValidation("file'.$unique.$i.'","req_file","File upload is required for '.$form_labels[$i].'!");';
else if($form_validations[$i] == "required" && $type == 'checkbox') $validator .= ' frmvalidator.addValidation("element'.$unique.$i.'","shouldselchk=Checked","You must select '.$form_labels[$i].'!");';
else if($form_validations[$i] == "required" && $type == 'alphabetic') $validator .= ' frmvalidator.addValidation("element'.$unique.$i.'","alpha","Enter alphabetic chars only for '.$form_labels[$i].'!");';
else if($form_validations[$i] == "required") $validator .= 'frmvalidator.addValidation("element'.$unique.$i.'","req","'.$form_labels[$i].' is a required field!"); ';
//process the types
switch($type){
case 'text':
$this_element = "<input type='text' name='element".$unique.$i."' id='element".$unique.$i."' class='form_elements' />";
Break;
case 'password':
$this_element = "<input type='password' name='element".$unique.$i."' id='element".$unique.$i."' class='form_elements' />";
Break;
case 'textarea':
$this_element = '<textarea name="element'.$unique.$i.'" id="element'.$unique.$i.'" class="form_elements" rows="8"></textarea>';
Break;
case 'file':
$this_element = '<input type="file" name="file'.$unique.$i.'" id="file'.$unique.$i.'" class="form_elements" />';
Break;
case 'email':
$this_element = "<input type='text' name='element".$unique.$i."' id='element".$unique.$i."' class='form_elements' />";
$validator .= ' frmvalidator.addValidation("element'.$unique.$i.'","email","Enter a valid email address for '.$form_labels[$i].'!");';
Break;
case 'numeric':
$this_element = "<input type='text' name='element".$unique.$i."' id='element".$unique.$i."' class='form_elements' />";
$validator .= ' frmvalidator.addValidation("element'.$unique.$i.'","numeric","Enter a numeric value for '.$form_labels[$i].'!");';
Break;
case 'alphabetic':
$this_element = "<input type='text' name='element".$unique.$i."' id='element".$unique.$i."' class='form_elements' />";
Break;
case 'checkbox':
$this_element = "<input type='checkbox' name='element".$unique.$i."' id='element".$unique.$i."' class='form_elements' value='Checked' />";
Break;
default:
$this_element = "<input type='text' name='element".$unique.$i."' id='element".$unique.$i."' class='form_elements' />";
Break;
}
$form_elements[$form_labels[$i]] = $this_element;
$cell_class[$form_labels[$i]] = ($form_validations[$i] == "required") ? "<span class='jxforms_red'>*</span>" : "";
}
if($showform):
?>
<style type="text/css">
<?php echo $params->get('form_css'); ?>
</style>
<script src="modules/mod_jxform/gen_validatorv4.js" type="text/javascript"></script>
<form action="" method="post" name="form<?php echo $unique; ?>" id="form<?php echo $unique; ?>" enctype="multipart/form-data" >
<table width="100%" border="0" cellspacing="5" cellpadding="0">
<input name="hiddenField" type="hidden" id="hiddenField" value='<?php echo serialize($hidden); ?>' />
<?php
//Get label position
$label_position = $params->get('label_position','0');
if($label_position != 0) $extra_row = ' colspan="2"'; else $extra_row = "";
foreach($form_elements as $key =>$value){
echo "<tr><td class='table_cell'>";
if($label_position == 0) echo $key.$cell_class[$key]."</td></tr><tr><td class='form_elements'>".$value;
else if($label_position == 1) echo $key.$cell_class[$key]."</td><td class='form_elements'>".$value;
else echo $value."</td><td class='form_elements'>".$key.$cell_class[$key];
echo "</td></tr>";
}
if($captcha_type == 0):
$_SESSION['jxforms_securitycode']=rand(1000,9999);
$jxforms_key=rand(1,9);
?>
<tr>
<td <?php echo $extra_row; ?> ><img src="modules/mod_jxform/captcha.php?width=150&height=40&characters=4&sessionVar=<?php echo $jxforms_key.rand(10,99).($_SESSION['jxforms_securitycode']*$jxforms_key);?>" /></td>
</tr>
<tr>
<td <?php echo $extra_row; ?>><span id="securityimagex">
<input name="jxforms_securitycode" type="text" class="form_elements" id="jxforms_securitycode" /><br />
<span class="textfieldRequiredMsg">Type the security code shown above!.</span></span></td>
</tr>
<?php
elseif($captcha_type == 1):
echo '<tr><td '.$extra_row.'>'.recaptcha_get_html($publickey, $error).'</td></tr>';
endif;
?>
<tr>
<td <?php echo $extra_row; ?> align="center">
<input type="submit" class="button" name="submit<?php echo $unique; ?>" id="submit<?php echo $unique; ?>" value="Submit" />
|
<input type="reset" class="button" value="Reset" />
</td>
</tr>
<?php
$disp_ = $params->get('display_link','block') ;
echo ' <tr>
<td colspan="2" align="center"><div style="display:'.$disp_.'" ><a href="http://www.afrisoft.org">JxForms</a></div></td>
</tr>';
?>
</table>
</form>
</div>
<script language="JavaScript" type="text/javascript" xml:space="preserve">//<![CDATA[ //You should create the validator only after the definition of the HTML form
var frmvalidator = new Validator("form<?php echo $unique; ?>");
frmvalidator.EnableMsgsTogether();
<?php echo $validator; ?>
//]]></script>
<?php endif;
?>
+++++++++++++++++++++++++++++++++++
Если что-то еще нужно показать, без проблем. Помогите, плиз.
$mailer =& JFactory::getMailer();
$body = '<style type="text/css">'.$params->get('form_css').'</style>';
$body .= '<table width="100%" border="0" cellspacing="5" cellpadding="0">';
$hiddenField = $_POST['hiddenField'];
$hiddenField = unserialize($hiddenField);
$attached_files = array();
$body .= "</table>";
$sender = array($params->get('sender'),$params->get('sender'));
$mailer->setSender($sender);
$mailer->addRecipient($params->get('recipient'));
$mailer->setSubject($params->get('subject'));
$mailer->isHTML(true);
$mailer->setBody($body);
if(!$mailer->Send()) {
echo "<div align='center' style='background-color:#F00; color:#FFF; width:90%; border:#000 thin double;'>Message Error: " . $mail->ErrorInfo.'</div>';
$showform=true;
} else {
echo "<div align='center' style='background-color:#F00; color:#FFF; width:90%; border:#000 thin double;'>".$params->get('success_message', 'Your message has been sent successfully! Thank you.')."</div>";
$showform=false;
}
судя по коду, в теле письма переменная $body
а она формируется выделенными строками, т.е. пустой таблицей
подскажите, плиз, что необходимо в переменную $body дописать? или эти строки вообще не нужны?
попробуй добавить после строки:
так, чисто поржать..
по хорошему нужно перебрать все поля формы и прилепить их
по хорошему нужно перебрать все поля формы и прилепить их
можете пример хотябы с несколькими полями подкинуть, плиз?
можете пример хотябы с несколькими полями подкинуть, плиз?
$body.=$_POST["имя_поля"];
сами поля посмотри в исходном коде страницы с формой
спасибо! щас взгляну)