묻고답하기
간단한 로그인을 만들고 싶은데 도와주세요
2012.03.14 21:06
<!-- backend.php source -->
<?php
$username = $_POST['username'];
$password = $_POST['password'];
if ($username == "test" && $password == "password")
{
print "<strong>Login succeeded!</strong>";
}
else
{
print "<strong>Login failed! Please try again.</strong>";
}
?>
일단 http://lifestory.mireenecom가 제 홈페이지입니다.
보니까 db를 연결해야 정상적으로 로그인이 된다는데
어떻게 연결을 해야되는지 모르겠더라구요...도와 주시면 감사하겠습니다.
___________________밑에는 전체 소스입니다__________________
<!-- login form source -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#login_form").submit(function() {
var unameval = $("#username").val();
var pwordval = $("#password").val();
$.post("backend.php", { username: unameval,
password: pwordval }, function(data) {
$("#status p").html(data);
});
return false;
});
});
</script>
</head>
<body>
<form id="login_form" method="post">
<p>Username: <input type="text" id="username" /></p>
<p>Password: <input type="password" id="password" /></p>
<p><input type="submit" value="Login" /></p>
</form>
<div id="status">
<p></p>
</div>
</body>
</html>
<!-- backend.php source -->
<?php
$username = $_POST['username'];
$password = $_POST['password'];
if ($username == "test" && $password == "password")
{
print "<strong>Login succeeded!</strong>";
}
else
{
print "<strong>Login failed! Please try again.</strong>";
}
?>
form의 input에 name값이 없네요