채택완료

if로 파일 업로드 했을 때 안했을 때 구분 짓고 싶습니다.

Copy
// config.php

<form action='./configupdate.php'>

    <input type='text' name='mb_name' id='mb_name'>

    <input type='file' name='test_image' id='test_image'>

    <label for='test_image'>파일첨부</label>

</form>

 

// configupdate.php

<?php

    $sql_common = "mb_name = '{$_post['mb_name']}'";

    if(isset($_files['test_image'])){

        $sql_common .= ", mb_1 = '1'";

    }

 

    $sql = "update g5_member set {$sql_common} where mb_id = '{$mb_id}' ";

    sql_query($sql);

?>

 

안녕하세요. 저녁은 맛있게 드셨나요?

파일선택을 안하고 그냥 올렸을때는 mb_1 = '1' 이게 적용 안되게 하고

파일을 선택했을때 mb_1 = '1' 으로 전송되게 하고싶습니다.

파일선택 유무에 대한 if문 처리를 어떻게 해야하나요...?

도움 부탁드립니다 ^^

답변 1개

채택된 답변
+20 포인트

Copy
$sql = "update g5_member set {$sql_common} where mb_id = '{$mb_id}' ";

if(isset($_files['test_image']))$sql = $sql . $sql_common;
sql_query($sql);

답변을 작성하려면 로그인이 필요합니다.