<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="java.sql.*,gbase.db.*" %>
<%
	
	String message="用户名重复，注册失败，请重新注册！";
	String flag="false";
	String username=request.getParameter("username")==null?"":request.getParameter("username").trim();
	String email=request.getParameter("email")==null?"":request.getParameter("email").trim();
	String type=request.getParameter("type")==null?"":request.getParameter("type").trim();
	String content=request.getParameter("content")==null?"":request.getParameter("content").trim();
	
        DBConnection dbConnection = new DBConnection();
        Connection conn=dbConnection.getConnection();
        PreparedStatement stmt=null;
        
        try {
        String sql = " insert into web_service(username,email,type,content) values(?,?,?,?)";
        stmt=conn.prepareStatement(sql);
        stmt.setString(1,username);
        stmt.setString(2,email);
        stmt.setString(3,type);
        stmt.setString(4,content);
        
        int i=stmt.executeUpdate();
        
        if(i>0)
          {
          
          message = "操作成功，我们会马上处理并以邮件的形式回复您！";
          flag="true";
          }
          
        else
          {
          message = "操作失败，请重新输入！";
          flag="false";
          }
      
      }
      catch (Exception ex) {
        message = "操作失败，请重新输入！";
        flag="false";
      }
      finally{
      if(stmt!=null)stmt.close();
      if(conn!=null && (!conn.isClosed()))conn.close();
      }
	
%>
<script language="javascript">
	function process ( message,flag){
		alert(message);
		if(flag=='false')
		self.location = "service.jsp";
		else
		self.location = "service.jsp";
	}
</script>
<html>
	<head>
		<title>客户服务</title>
	</head>
	<body onload="javascript: process('<%=message%>','<%=flag%>');">
	</body>
</html>