2010-02-24 3 views
0

사용자 프로필에는 다른 사용자가 자신의 프로필에 의견을 게시 할 수있는 주석 상자가 있습니다. A. 자신의 프로필을보고있는 경우에 따라 텍스트 상자 변경 B. 다른 사람 프로필보기 C. 전혀 로그인하지 않았 음두 개의 if (isset 문이 작동하는 삽입 쿼리를 얻으려면 어떻게해야합니까?

나 자신이있을 때 "업데이트"를 구현하려고합니다. 페이지에서 주석 상자에 입력하면 페이지의 지정된 영역에 출력됩니다 (아직 커뮤니티 페이지에는 출력하지 않지만 아직 커뮤니티 페이지에는 출력하지 않습니다)

이 프로필 페이지에는 다음과 같은 삽입 쿼리가 있습니다. 정기적 인 주석 삽입 (첫 번째 삽입 쿼리) 이제 두 번째 if (isset 문을 두 번째 삽입 쿼리와 함께 추가하고이 작업을 수행하는 데 문제가 있습니다.

제출 버튼을 누르면 페이지가 삽입되지 않고 페이지가로드됩니다. 나는 PHP btw를 가진 초보자이다.

/* code chunk for the regular comments that is working just fine */ 

     if(isset($_POST['commentProfileSubmit']) && $auth) { 

     $query = "SELECT `Email` FROM `Users` WHERE `id` = '" . $prof->id . "'"; 
     $request = mysql_query($query,$connection) or die(mysql_error()); 
     $result = mysql_fetch_array($request); 

     $Email = $result['Email']; 


     $to = $Email; 
     $subject = "$auth->first_name $auth->last_name left you a comment"; 
     $message = "$auth->first_name $auth->last_name left you a comment: <br /><br /> <a href='http://www.blah.org/Profile.php?id=" . $prof->id . "'>Click here to view</a><br /><br />"; 
     $from = "blah <[email protected]>"; 
     $headers = 'MIME-Version: 1.0' . "\r\n"; 
     $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
     $headers .= "From: $from"; 
     mail($to, $subject, $message, $headers); 



     $query = "INSERT INTO `ProfileComments` 
           (`FromUserID`, 
            `ToUserID`, 
            `commentProfileBody`, 
            `status`, 
            `date`, 
            `time` 

            ) VALUES (

           '" . $auth->id ."', 
           '" . $prof->id ."', 
               '" . mysql_real_escape_string($_POST['ProfileComment']) ."', 
           'active', 
           '" . date("Y-m-d") . "', 
           '" . date("G:i:s") . "')"; 

    mysql_query($query,$connection); 

    /* code chunk that is not inserting the desired info into the db and loading the page blank when I hit submit */ 

     }elseif(isset($_POST['airwaveSubmit']) && $auth) { 

     $query2 = "INSERT INTO `Airwaves` 
          (`id`, 
          `body`, 
          `status`, 
          `date`, 
          `time` 

          ) VALUES (

          '" . $auth->id ."', 
          '" . $mysql_real_escape_string($_POST['body']) . "', 
          'active', 
          '" . date("Y-m-d") . "', 
          '" . date("G:i:s") . "')"; 

              mysql_query($query,$connection);  

      } 
     ?> 

    /* dynamic text/areas with dynamic submit buttons which is working how it should but want to include in case there is something on here that is causing the previous troubles */ 

<div id="commentBoxBlog"> 
<form name="CommentBox" method="post" action="Profile2.php?id=<?php echo $prof->id; ?>"> 
    <?php if($auth->id == $prof->id) { 
    echo "<div id='counter'> 
    <span id='counter_airway'>140 Character Limit</span> 
    </div>"; 
    echo "<textarea name='airwaveBody' class='round_10px' onkeyup='limit_length(this,140,\"counter_airway\");'></textarea> <input type='submit' name='airwaveSubmit' value='Exhale' class='post'/>";} elseif(!$auth) { 
echo "<textarea name='ProfileComment' class='round_10px' disabled>Please sign in to comment...</textarea>"; } elseif($auth->id != $prof->id) 
    echo "<textarea name='ProfileComment' class='round_10px'></textarea> 
    <input type='submit' name='commentProfileSubmit' value='Exhale' class='post' />"; 

    ?> 
    </form> 
</div> 
+0

PHP 오류 로그에는 어떤 것이 있습니까? –

+0

오류 로그가 해제되어 있습니다. 초보자 인 나는 내 사이트의 기능을 손상시키지 않는 약간의 단점을 가지고 있지만 사용자가 많아서 사이트가 손상된 것처럼 보이게하고 오류 표시를 현명하게 보일 것입니다. –

답변

2

당신은 $ 쿼리 2라는 변수에 SQL을 넣어,하지만하여 mysql_query()는라는 변수 $ 쿼리를 사용하여 데이터베이스로 전송 전화 : 감사합니다.

+0

여전히 페이지가 비어 있고 삽입되지 않습니다. 그것은 잘 알고 있습니다. 감사 –

관련 문제