admin 및 user에 대한 라디오 버튼이있는 HTML 로그인 페이지가 있는데, 사용자가 "admin"을 선택하면 관리자 로그인 페이지로 리디렉션되어야하며 "user" 다음은 사용자 로그인 페이지로 이동합니다PHP 로의 HTML 리디렉션
html로 로그인 페이지는 다음과 같이 주어진다 :.
<!-- THE LOG IN PAGE -->
<div id="id01" class="modal">
<form name="login" id="login" class="modal-content animate" action="login.php" method="post">
<div class="imgcontainer">
<span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">×</span>
<img src="images/avatar.png" alt="Avatar" class="avatar">
</div>
<div class="container">
<label><b>Email Id:</b></label>
<input type="text" placeholder="Enter Email Id" name="email" id="email" required>
<label><b>Password:</b></label>
<input type="password" placeholder="Enter Password" name="psw" id="psw" required>
<label><b>User Type:</b></label>
<table width="100%">
<tr>
<td><input type="radio" name="usertype" id="usertype" value="admin" required>ADMIN</td>
<td><input type="radio" name="usertype" id="usertype" value="user" required>USER</td>
</tr>
</table>
<button type="submit">Login</button>
<input type="checkbox" checked="checked"> Remember me
<span class="psw"><a href="#">Forgot password?</a></span>
<button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancelbtn">Cancel</button>
</div>
</form>
<script>
// Get the modal
var modal = document.getElementById('id01');
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event)
{
if (event.target == modal)
{
modal.style.display = "none";
}
}
</script>
</div>
사용자에 대한 admin_login.php 페이지가 아래와 같습니다 :
<?php
으로 session_start()를 ;
$ email = $ _ POST [ "email"];
$ psw = $ _ POST [ "psw"];
$ name = "";
에는 'db_config.php'가 포함됩니다.
$ sql = "이름, 비밀번호, 이메일 FROM admin_details from email = '$ email'";
$ result = $ conn-> query ($ sql);
다른
{
echo '<script type="text/javascript">';
echo 'alert("You must REGISTER first and then LOGIN !!!");';
echo 'window.location.href = "admin_index.php";';
echo '</script>';
}
,617 ($에서 그 결과> NUM_ROWS> 0){
// output data of each row
while($row = $result->fetch_assoc())
{
$name=$row['name'];
if($psw == $row['password'])
{
$_SESSION['name']=$name;
$_SESSION['email']=$email;
header('Location: admin_index.php');
}
else
{
echo '<script type="text/javascript">';
echo 'alert("WRONG PASSWORD ENTRY. TRY LOGGING IN AGAIN !!!");';
echo 'window.location.href = "admin_index.php";';
echo '</script>';
}
}
}
경우
$ conn-> close();
>
여기서 리디렉션에 사용되는 PHP 스크립트는 무엇입니까? –
Javascript 또는 PHP를 사용하는 두 가지 방법이 있습니다 (요소 값을 가져 와서 비교하고 리디렉션 함) –
사람, 눈에 괴롭다 ... 온라인 형식 지정 기나 뭔가를 통해 던져보십시오. 이건 꽤 괜찮은 것 같아요. http://www.freeformatter.com/html-formatter.html –