무소의 뿔처럼

(회원등록)과정평가형 정보처리산업기사 홈쇼핑 회원관리 프로그램 본문

과정평가_정산기_기록/홈쇼핑 회원관리 프로그램

(회원등록)과정평가형 정보처리산업기사 홈쇼핑 회원관리 프로그램

값을변경 2022. 2. 12. 18:04

 

정보처리산업기사_2차 평가문제(공개용).pdf
0.43MB

 


 

회원번호 자동생성

String sql ="select max(custno)+1 custno from member02";

 

입력  jsp

더보기
<%@page import="DBPKG.dbcon"%>
<%@page import="java.sql.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

			
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	
	<jsp:include page="header.jsp"></jsp:include>
	    
    <%
    Connection con = null;
	Statement stmt = null;
	ResultSet rs = null;
	
	String custno = "";
	try{
		
		con = dbcon.getConnection();
		stmt = con.createStatement();
		String sql ="select max(custno)+1 custno from member02";
		rs = stmt.executeQuery(sql);
		rs.next();
		custno = rs.getString("custno");

		    if(rs!=null) rs.close();
			if(stmt!=null) stmt.close();
			if(con!=null) con.close();
	}catch(Exception e){
		e.printStackTrace();
	}
		%>
	
	<section>
	
		<h3>홈쇼핑 회원 등록</h3>
		
		<div class="tablediv">
	
<form name="regiform" action="regiAction.jsp">
			<table>
				<tr>
				<th>회원정보(자동발생)</th>
					<td><input name="custno" readonly="readonly" value="<%=custno%>"></td>
				</tr>

				<tr>
					<th>회원성명</th>
					<td><input name="custname"></td>
				</tr>
				<tr>
					<th>회원전화</th>
					<td><input name="phone"></td>
				</tr>
				<tr>
					<th>회원주소</th>
					<td><input name="address"></td>
				</tr>
				<tr>
					<th>가입일자</th>
					<td><input name="joindate"></td>
				</tr>
				<tr>
					<th>고객등급[A:VIP,B:일반,C:직원]</th>
					<td><input name="grade"></td>
				</tr>
				<tr>
					<th>도시코드</th>
					<td><input name="city"></td>
				</tr>
				<tr>
					<td colspan="2" style="text-align: center">
						<input type="submit" value="등록" onclick="return check()">
						<input type="button" value="조회" onclick="location.href='list.jsp'">
					</td>
				</tr>
			</table>
</form>
		</div>

		
	</section>
	<jsp:include page="footer.jsp"></jsp:include>
</body>
</html>

 

입력Action.jsp

더보기
<%@page import="DBPKG.dbcon"%>
<%@page import="java.sql.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>

<%

String custno = request.getParameter("custno");
String custname = request.getParameter("custname");
String phone = request.getParameter("phone");
String address = request.getParameter("address");
String joindate = request.getParameter("joindate");
String grade = request.getParameter("grade");
String city = request.getParameter("city");


	Connection con = null;
	PreparedStatement pstmt = null;
	
	try{
		
		con = dbcon.getConnection();
		String sql = "insert into member02 values(?, ?, ?, ?, ?, ?, ?)";
		pstmt = con.prepareStatement(sql);
		pstmt.setString(1, custno);
		pstmt.setString(2, custname);
		pstmt.setString(3, phone);
		pstmt.setString(4, address);
		pstmt.setString(5, joindate);
		pstmt.setString(6, grade);
		pstmt.setString(7, city);
		pstmt.executeQuery();
		
		response.sendRedirect("regi.jsp");
		
		if(pstmt!=null) pstmt.close();
		if(con!=null) con.close();
		
	}catch(Exception e){
		e.printStackTrace();
	}
%>
			
	
</body>
</html>

 

 


알림창 / 포커스

if(document.regiform.custname.value.length==0){
		alert("회원성명이 입력되지 않았습니다.");
		regiform.custname.focus();
		return false;
	}

 

자바스크립트 전체

더보기
function check(){
	if(document.regiform.custname.value.length==0){
		alert("회원성명이 입력되지 않았습니다.");
		regiform.custname.focus();
		return false;
	} 
	if(document.regiform.phone.value.length==0){
		alert("핸드폰번호가 입력되지 않았습니다.");
		regiform.phone.focus();
		return false;
	} 
	if(document.regiform.address.value.length==0){
		alert("주소가 입력되지 않았습니다.");
		regiform.address.focus();
		return false;
	} 
	if(document.regiform.joindate.value.length==0){
		alert("가입일자가 입력되지 않았습니다.");
		regiform.joindate.focus();
		return false;
	} 
	if(document.regiform.grade.value.length==0){
		alert("고객등급이 입력되지 않았습니다.");
		regiform.grade.focus();
		return false;
	} 
	if(document.regiform.city.value.length==0){
		alert("도시가 입력되지 않았습니다.");
		regiform.grade.focus();
		return false;
	} 
	
	alert("회원등록이 완료 되었습니다.");
	return true;
}

 

 

 

Comments