[Normaltic's 취업반 과제] 회원가입
2024. 4. 26. 17:30ㆍ정보보안 및 해킹/Normaltic's 취업반 과제
login.php - 회원가입 버튼 추가 및 sign_up.php redirect
[생략]
<button class="submit-button" name="signup" value="signup">Sign up </button>
[생략]
if (isset($_POST['signup'])) {
header("location: sign_up.php");
exit;
}
[생략]
sign_up.php - 회원가입 양식 및 DB에 회원 양식 삽입 이벤트 call
<?php
require_once ('sign_up_func.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rame's Website Signup</title>
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="font.css" />
</head>
<body class="header">
<div class="info">
<form action="" method="POST">
<h1 class="title-text ">Sign Up</h1>
<h3 class="login-text">Create User</h3>
<label for="createid"> ID : </label><br>
<input type="text" name="createid" placeholder="UserID" /><br>
<label for="createpassword"> PASSWORD : </label><br>
<input type="password" name="createpassword" placeholder="UserPassword" /><br>
<label for="createage"> AGE : </label><br>
<input type="age" name="createage" placeholder="UserAge" /><br>
<label for="createemail"> EMAIL : </label><br>
<input type="email" name="createemail" placeholder="UserEmail" /><br>
<label for="createphone"> PHONENUMBER : </label><br>
<input type="tel" name="createphone" placeholder="UserPhonenumber" /><br>
<button name="createaddress" value="create">Sign up </button>
<?php
if (isset($_POST['createaddress'])) {
echo "sign up";
try_signup($_POST['createid'], $_POST['createpassword'], $_POST['createage'], $_POST['createemail'], $_POST['createphone']);
}
?>
</div>
</body>
</form>
</html>
sign_up_func.php - DB에 회원가입 양식데로 케이블에 row 추가
<?php
require_once ('connect_db.php');
function try_signup($username, $userpassword, $userage, $useremail, $userphone)
{
if (!connect_db()) {
die("Connection failed: " . mysqli_connect_error());
}
$table_name = "rame_table";
$sql_query = "INSERT INTO $table_name VALUES (NULL, '$username', '$userpassword', '$userage', '$useremail', '$userphone')";
$sql_res = mysqli_query(connect_db(), $sql_query);
if ($sql_res) {
header("location: index.php?login_id=" . $username);
exit;
}
}
?>
'정보보안 및 해킹 > Normaltic's 취업반 과제' 카테고리의 다른 글
[Normaltic's 취업반 과제] 회원가입 시 ID 중복 확인 (0) | 2024.04.29 |
---|---|
[Normaltic's 취업반 과제] My Page (0) | 2024.04.28 |
[Normaltic's 취업반 과제] 게시판 (0) | 2024.04.27 |
[Normaltic's 취업반 과제] 로그인 DB 연동 (0) | 2024.04.26 |
[Normaltic's 취업반 과제] Login Page (0) | 2024.04.24 |