mysql 쿼리문 php 질문
-
게시물 수정 , 삭제는 로그인 필요
여기서 $result를 가져오는 변수에서는 전부 오류가나는데 쿼리문이 잘못된건가요 ???
이게 db구요
<?
function login($userid, $passwd){
global $con;
global $table;
global $errormsg;
$userid=$_POST['userid'];
$passwd=$_POST['passwd'];
if(!isset($_COOKIE["isOK"])){
$query="select id, passwd from $table where id='$userid'";
$result =mysql_query($query, $con);
if(mysql_num_rows($result)){
$errormsg="계정이 없습니다";
return 0;
}
else {
$dbid=mysql_result($result,0,"id");
$dbpasswd = mysql_result($result, 0, "passwd");
if($dbid==$userid AND $dbpasswd == $passwd){
SetCookie("isOK", $userid, time()+10, "/");
return 1;
}
else {
$errormsg=$userid."님 패스워드가 틀렸습니다";
return 0;
}
}
}
else // if(!isset($isOK)의 else 부분
{
SetCookie("isOK", $userid, time()+10, "/");
return 2;
}
}
$table="T_cookie";
$con=mysql_connect('localhost', 'djkim','pass');
mysql_select_db('pass',$con);
$login_result = login($userid, $passwd);
?>
<HTML>
<HEAD><TITLE>로그 인</TITLE></HEAD>
<BODY link='white' vlink='white' alink='orange'>
<center>
<?
if($login_result == 0) {
print $errormsg."<br>";
print "<font color=blue size=4>필요하면 로그인 하십시요.</font></center><br>";
- 3 -
print "<table align='center'><tr>
<td align=center bgcolor='#000099'><font color=white><a href='ck_main.html'>
메인화면으로 가기</a></font></td></tr></table></BODY></HTML>";
}
else {
if($login_result == 1) {
print $_POST['userid']."님 인증되었습니다. 그 동안 안녕하셨습니까 ?";
}
if($login_result == 2) {
print $_POST['userid']."님 이미 인증되신 분입니다.
<br>유효시간이 10초 연장되었습니다";
}
print "<center><font color=blue size=4>다음 중 기능을 클릭해 주십시요</font>
</center><br>
<table align=center cellpadding='5' cellspacing='2'><tr>
<td align=center bgcolor='#CCCCFF'><font color=black><a href='confirm.php'>
서비스 사용 가능성 확인하기</font></td>
<td align-center bgcolor='#000099'><font color=white><a href='logout.php'>
로그아웃 하기</a></font></td></tr></table>";
}
?>
</center>
#mysql 쿼리문 #mysql 쿼리문 예제 #mysql 쿼리문 실행 #mysql 쿼리문 추출 #mysql 쿼리문 입력 #mysql 쿼리문 여러개 #mysql 쿼리문 update #mysql 쿼리문 모음 #mysql 쿼리문 저장 #mysql workbench 쿼리문