Commit 109046a7 authored by Fabian Dewantara Santonie's avatar Fabian Dewantara Santonie 🕊

Menambahkan Form Registrasi

parent 23173433
......@@ -24,12 +24,6 @@ public class halamanLogin extends HttpServlet {
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession session = request.getSession(false);
if(request.getParameter("logout")!=null) {
session.invalidate();
response.sendRedirect(request.getContextPath());
}
}
@SuppressWarnings("deprecation")
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
......
package org.tugasAkhir.servlet;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class userBaru
*/
@WebServlet("/userBaru")
public class userBaru extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public userBaru() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("Served at: ").append(request.getContextPath());
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
try {
Connection con = DatabaseConnection.initializeDatabase();
PreparedStatement st = con.prepareStatement("insert into tbl_user values(?,?,?,?)");
st.setString(1, request.getParameter("id"));
st.setString(2, request.getParameter("nama"));
st.setString(3, request.getParameter("email"));
st.setString(4, request.getParameter("password"));
st.executeUpdate();
st.close();
con.close();
response.sendRedirect(request.getContextPath()+"/Login.jsp");
}
catch (Exception e){
}
}
}
......@@ -24,6 +24,7 @@
</table>
<button type="submit" class = "btn btn-primary">Login</button>
</form>
<a href="Registrasi.jsp" class="link-secondary">Belum punya akun? Daftar</a>
</div>
</form>
</body>
......
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<head>
<meta charset="ISO-8859-1">
<title>Ngeteh.com</title>
</head>
<body>
<div align="center">
<h1>Daftar User Baru</h1>
<h6>Masukan Data Diri Anda</h6>
<form name="loginForm" method="post" action="userBaru">
<table class="table-sm">
<tr>
<td>ID</td>
<td><input type="text" class="form-control" id="id" name="id" maxlength="100" required placeholder="Masukan ID..."></td>
<tr>
<td>Nama Lengkap</td>
<td><input type="text" class="form-control" id="nama" name="nama" maxlength="100" required placeholder="Masukan Nama Anda..."></td>
</tr>
<tr>
<td>E-Mail</td>
<td><input type="email" class="form-control" id="email" name="email" required placeholder="Masukan Email..."></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" class="form-control" id="password" name="password" minlength="8" required placeholder="Password..."></td>
</tr>
</table>
<input type="submit" class="btn btn-light" value="Submit Data">
<input type="reset" class="btn btn-light" value="Reset">
<br><br>
</form>
</div>
</form>
</body>
</html>
\ No newline at end of file
......@@ -5,7 +5,7 @@
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
<title>Ngeteh.com</title>
</head>
<body>
<div align="center">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment