티스토리 뷰

회원가입을 위한 폼과 DB에 저장하는 코드입니다!

css는 각자의 취향에 맞춰 만들어주시면 됩니다.

직접 만든 코드라 서툴다는 점 참고해주세요 ㅎㅎ

 

 

<register.php>

<!DOCTYPE html>
<html lang="en">
<head>
	    <meta charset="utf-8">
	    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	    <link rel="stylesheet" type="text/css" href="main.css">
      
		<title>Duni's web page</title>
	</head>

	<center>
		<body><br><br>
		<h1>Account Register</h1>
			<form method="post" action="./membersave.php">

			<div data-validate= "Enter NAME">
			<input type="text" name="name" placeholder="NAME">
			</div><br>
			
			<div data-validate= "Enter ID">
				<input type="text" name="userId" placeholder="Id">
			</div><br>

			<div data-validate= "Enter PASSWORD">
				<input type="password" name="userPw" placeholder="PASSWORD">
			</div><br>

			<div data-validate= "Enter PASSWORD2">
				<input type="password" name="userPw2" placeholder="PASSWORD CHECK">
			</div><br>
			
			<button type="submit">REGISTER</button>
			<button type="button"> <a href="./logIn.php">CANCEL</a></button>
	
			</form>

	</body>
	</center>
</html>

 

<membersave.php>

<?php

include "./dbConnect.php"; //dbConnect.php는 회원가입 후 정보가 저장되는 DB와 연동

$name=$_POST['name'];
$userId=$_POST['userId'];
$userPw=$_POST['userPw'];
$userPw2=$_POST['userPw2']; 

    if($userPw == $userPw2) {
		$sql = "insert into member (name,userId, userPw)";
		$sql = $sql."values('$name', '$userId', '$userPw')";

	if($mysqli->query($sql)){
		echo "<script>alert('Success');location.href='index.php';</script>";

	}else{
		echo "<script>alert('Failed');location.href='register.html';</script>";
	}
	}
	else {
		echo "<script>alert('no match');location.href='register.html';</script>";
	}
?>

 

 

 

<결과물>

 

 

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday