我应该在哪里粘贴我的html表单代码在joomla?

时间:2013-09-30 16:03:20

标签: php html joomla joomla2.5

我在joomla工作我有一个custom contact form 我已在html code中创建了该内容,当用户点击submit按钮时 我应该向我提供所有文本框值email

所以我为此写了php code

例如

只有两个领域 在HTML代码中 在PHP代码中如下

<?php
if(isset($_POST['email'])) {


    $email_to = "test@gmail.com";
    $email_subject = "mail";


    function died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
    }

    // add  validation for other fields if needed 
    if(!isset($_POST['Applicant_name']) ||
        !isset($_POST['email']))) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');       
    }

     //all fields with there name to send in email
    $name = $_POST['name']; // required
    $email= $_POST['email']; // required


    $error_message = "";

  if(strlen($error_message) > 0) {
    died($error_message);
  }
    $email_message = "Form details below.\n\n";

    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }

     //show all fields in message body
    $email_message .= "Applicant_name: ".clean_string($Applicant_name)."\n";
    $email_message .= "name: ".clean_string($dob)."\n";
    $email_message .= "email: ".clean_string($sex)."\n";

// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);  
?>

Thank you for contacting us. We will be in touch with you very soon.

<?php
}
?>
  

我需要在Joomla中粘贴此代码的地方和方式?

3 个答案:

答案 0 :(得分:3)

安装扩展程序以处理表单更容易。

我建议您install RSform Pro

功能&amp;优点

  • 使用提交的数据发送自定义的HTML /文本电子邮件
  • 将收集的数据导出为CSV格式
  • 字段验证规则可自定义谢谢 消息
  • 可自定义的感谢信息

答案 1 :(得分:1)

如果您决定使用自己的代码,请转到&#34; ADMIN end&#34; 。点击&#34;新&#34;然后选择&#34;自定义html&#34;输入并简单地粘贴代码。现在为您的模块命名并在任何需要的地方发布。

答案 2 :(得分:0)

为什么不使用核心联系表单并制作插件来添加一些字段。

相关问题