테스트 사이트 - 개발 중인 베타 버전입니다

php if? else? 질문인거같아요!

· 13년 전 · 692 · 3
  <?
     include_once("./connect_db.php");
 $code = $_POST["code"];
 
if($member[mb_id]){
    $query=mysql_query("update '$dataname' set occupant='$member[mb_id]',regdate='$date' where code='$code' limit 1",$connect);
}else{
    alert('로그인 해주세요');
}
?>
포스트로 받아온 $code 가 db안에 있는 code 와 일치하는것이 없다면 없는 코드라고 띄우고싶은데 어떻게 해야할까요?

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 3개

먼저 select 해보시면 될듯 합니다.
<?
if($memeber[mb_id]) {
$query = mysql_query("select count(*) from $dataname where code=$code");
$result = mysql_fetch_row($result);
if($result[0] >0 ) {
$query=mysql_query("update '$dataname' set occupant='$member[mb_id]',regdate='$date' where code='$code' limit 1",$connect);
} else {
echo "코드가 없습니다. 다시 시도하여 주십시오."
}
}else{
alert('로그인 해주세요');
}
?>
13년 전
밴닛님이 설명 해주셨네요 ㅎㅎ db안에 있는 code를 먼저 뽑아야 겠죵 ㅎㅎ
13년 전
감사

게시글 목록

번호 제목
12413
12412
12411
12410
12407
12406
12405
12404
12403
12402
12401
12400
12399
12398
12397
12396
12395
12394
12393
12392
12391
12390
12389
12388
12387