dtsc1684 2012-10-10 10:25
浏览 52
已采纳

Liferay中的HTML表单

I have made a simple HTML form in Liferay. When the form is submitted, its content should go to my email address and a line saying 'thank you' is to be displayed. I have done the action part with php. But after submitting, all I get is the 'thank you' part and the form doesn't get submitted to my email address.

Any idea why this doesn't work? I am not good with PHP at all. Only the basics.

Is there any other way to do this? e.g with javascript? though that might not be a good option.

I am using Liferay 6.1 and Tomcat 7.

HTML form:

<form name="form" method="post" action="form.php">
<table>
</tr>
<tr>
 <td>
  <label for="first_name">First Name</label>
 </td>
 <td>
  <input  type="text" name="first_name" maxlength="50" size="30">
 </td>
</tr>

<tr>
 <td>
  <label for="last_name">Last Name</label>
 </td>
 <td>
  <input  type="text" name="last_name" maxlength="50" size="30">
 </td>
</tr>
</table>
</form>

PHP:

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

    // Email where form is sent:
    $email_to = "myemail@mydomain.com";


Thank you!

<?php
}
die();
?>
  • 写回答

4条回答 默认 最新

  • dsdxlibt98300 2012-10-12 09:59
    关注

    Finally got the answer with JSP, which I haven't used since school days. Here is the code in case someone wanted to try it.

    <%@ page import="sun.net.smtp.SmtpClient, java.io.*, javax.servlet.http.HttpServletResponse, javax.servlet.jsp.PageContext,java.util.*" %>
    <%
     String from= request.getParameter("from");
     String to= request.getParameter("to");
    
     try{
         SmtpClient client = new SmtpClient("smtp.mysitedomain.com");
         client.from(from);
         client.to(to);
         PrintStream message = client.startMessage();
         message.println("From: " + from);
         message.println("To: " + to);
         message.println();
         Enumeration paramNames = request.getParameterNames();
         while(paramNames.hasMoreElements()) {
           String paramName = (String) paramNames.nextElement();
           String paramValue = request.getParameter(paramName);
           message.println(paramName + ":" + paramValue);
          }
         client.closeServer();
      }
      catch (IOException e){    
         System.out.println("ERROR IN DELIVERING THE FORM:"+e);
      }
     response.sendRedirect("thanks.htm");
    %>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?