메뉴 건너뛰기

XEDITION

project2018

[WEB] 회원가입 부분 기본 틀

proin 2018.06.04 11:53 조회 수 : 1

signup.html

<!doctype html>

<html lang = "ko">

<head>

<meta charset = "utf-8">

<title>회원가입</title>

</head>

<body>

<h1>회원가입</h1>

<form action = "signup.php" method = "post">

<table>

<tr>

<td>이름</td>

<td><input type = "text" name = "name" placeholder = "이름" maxlength = "10" /></td>

</tr>

<tr>

<td>ID</td>

<td><input type = "text" name = "id" placeholder = "ID" maxlength = "15" /></td>

</tr>

<tr>

<td>비밀번호</td>

<td><input type = "password" name = "pw" placeholder = "비밀번호" maxlength = "20" /></td>

</tr>

<tr>

<td>비밀번호 확인</td>

<td><input type = "password" name = "re_pw" placeholder = "비밀번호 확인" maxlength = "20" /></td>

</tr>

<tr>

<td>E-mail</td>

<td><input type = "email" name = "email" placeholder = "E-mail" maxlength = "30" /></td>

</tr>

<tr>

<td colspan = "2"><input type = "submit" value = "회원가입" /></td>

</tr>

</table>

</form>

</body>

</html>

 


signup.php

<!doctype html>

<html lang = "ko">

<head>

<meta charset = "utf-8">

<title>회원가입</title>

</head>

<body>

<?php

$name = $_POST['name'];

$id = $_POST['id'];

$pw = $_POST['pw'];

$re_pw = $_POST['re_pw'];

$email = $_POST['email'];

//빈칸 확인

if($name == "")

{

echo "<script>alert('이름 칸이 비어있습니다.'); history.back();</script>";

exit;

}

else if($id == "")

{

echo "<script>alert('아이디 칸이 비어있습니다.'); history.back();</script>";

exit;

}

else if($pw == "")

{

echo "<script>alert('비밀번호 칸이 비어있습니다.'); history.back();</script>";

exit;

}

else if($re_pw == "")

{

echo "<script>alert('비밀번호 확인 칸이 비어있습니다.'); history.back();</script>";

exit;

}

else if($email == "")

{

echo "<script>alert('이메일 칸이 비어있습니다.'); history.back();</script>";

exit;

}

//비밀번호 체크

if($pw != $re_pw)

{

echo "<script>alert('비밀번호와 비밀번호 확인이 서로 다릅니다.'); history.back();</script>";

exit;

}

//MySQL 연결

$sql = mysqli_connect("localhost", "root", "pass", "poly");

//MySQL 연결 실패

if(mysqli_connect_errno())

{

echo "MySQL 연결 실패 : " .mysqli_connect_error();

}

?>

</body>

</html>

위로