DB 없이 로그인 아이디 비번 매치확인?

oppa의 이미지
<html>
	<head>
		<link rel="stylesheet" type="text/css" href="style.css">
	</head>
<body>
  <h1 align="center" class="style1">Log-in</h1><hr><br />
 
	  <form name="login" action="login.php" method="GET">
 
		<label>
		<div align="center" class="style2">User Name:</div>
		</label>
		<div align="center">
		  <input type="text" name="urname" value="" /><br/>
		</div>
 
		<label>
		<div align="center" class="style2">Password:</div>
		</label>
		<div align="center">
		  <input type="password" name="pass" value="" /> <br/>
		</div>
 
		<div align="center">
		<input type="submit" name="submit" value="login" />
		</div>
	  </form>  
 
</body>
</html>

이렇게 로그인 페이지를 html 로 만들고 아래와 같이 php 파일을 만들때 아이디나 비번을 틀리게 입력해도 아이디와 비번이 맞다고 나오는데 정확하게
아래의 부분에 $req->urname 와 $req->pass 이 맞는가요?
if ( $_GET[‘urname’] = $req->urname && $_GET['pass'] = $req->pass)

<div align="center">
<?php
 
$req = (object) $_REQUEST;
 
echo "<b><h1>Log in Result</h1></b><hr>";
 
if ( $_GET[‘urname’] = $req->urname && $_GET['pass'] = $req->pass) 
	{
		echo "*right username and password." . "<br />";
	} 
	else 
	{
		echo "*username or password wrong." . "<br />";
	}
 
?>
 
	<br />
	<form method="GET" action="edit.html">
    <button type="submit">Edit Account Info</button>
    </form>
 
</div>
yukariko의 이미지

= 연산자는 대입 연산자로, 서로 같은지 여부를 검사하려면 == 연산자를 사용해야 합니다.
언어에 대한 공부가 아직 부족하신것 같네요.

oppa의 이미지

=== 세개 넣었는데 왜 = 하나만 나왔는지!!!

익명 사용자의 이미지

이번 학기 프로젝트 과제인가 본데
숙제는 스스로.

김정균의 이미지

일단 '=' 문자를 3개로 했는데 1개로 나오는 건 두루팔 버그인 것 같고요..

코드 자체의 문제는 $_GET['urname'] 과 $_REQUEST['urname'] 은 동일합니다. 그러니 당연히 항상 true가 될 수 밖에 없지요. 비교할 정보는 따로 가지고 있어야 합니다. http://kr.php.net/manual/en/language.variables.external.php 참조 하세요.

그리고, $req->urname은 위에서 $_REQUEST 배열을 $req 변수에 object 형으로 변환을 해 놓았기 때문에, $_REQUEST['urname']과 $req->urname은 동일합니다. (위의 코드에서..)

oppa의 이미지

답변감사합니다. 그러면 처음 html 파일에서 사용자가 입력한 "urname" 과 "pass" 의 값을 어떻게 $req->urname 과 $req->pass 대신 넣어주어야 하나요? 혹시 $urname and $pass 이렇게 넣어주니 에러가 나는데 input 받은 정보를 어떻게 표현하죠?

김정균의 이미지

님의 코드에서 사용자가 입력한 urname과 pass가 $req->urname과 $req->pass 입니다. 다시 말하자면, 사용자가 입력한 값은 님의 코드에서 다음과 같이 사용할 수 있습니다.

$_GET['urname']
$_REQUEST['urname']
$req->urname ($req가 $req = (objecct) $_REQUEST; 로 할당이 되었으므로..)

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.