2013-03-24 97 views
-1

林試圖使一個消息系統,並且當所述接收器被讀出的消息那裏有一個鏈接到回覆消息,如下:如何從php中隱藏查詢字符串?

<a href=mail.php?action=compose&toid='".urlencode($viewrow['sender'])."'&subject='RE:+".urlencode($viewrow['subject'])."'&message=".urlencode($viewrow['message']).">Reply</a> 

的發送者,主題和消息正在從MySQL檢索。

用戶是看到這樣的:

http://www.somesite.com/author/mail.php?action=compose&toid='8'&subject='RE:+test+subject'&message=test+message 

什麼,我需要知道的是,如果那裏有辦法隱藏的主題和回覆的網址信息,因此用戶只能地址欄上看到:

http://www.somesite.com/author/mail.php?action=compose&toid='8' 

這是如何從數據庫中檢索主題,消息和ID。

//view message 
if (isset($_GET['action']) && $_GET['action'] == inbox) { 
     if(isset($_GET['viewid'])) { 
      $viewid = $_GET['viewid']; 
    /*  $viewsql = "select * from mail where reciever='".$userid."' and mail_id=".$viewid; */ 
      $viewsql = "select * from mail, authors where (mail.sender = authors.id) and (mail.reciever = '".$userid."') and (mail.reciever_deleted ='0') and mail.mail_id = ".$viewid; 
      $viewquery = mysql_query($viewsql,$connection) or die(mysql_error()); 
      $viewrow = mysql_fetch_assoc($viewquery); 
      if ($viewrow['reciever'] == $userid) { //check if user is the reciever 
      } else { 
       header('Location: mail.php?action=inbox'); 
       exit; 
      } 
      echo "<h3>Lendo mensagem particular da Caixa de Entrada</h3>"; 
      echo "<table align=\"center\" width=\"75%\" class=\"sortable\"> 
        <tr> 
         <td colspan='2' style=\"text-align:center;font-weight:normal;\">Mensagem particular enviada por ".$viewrow['displayname']." em ".date('d/m/y',strtotime($viewrow['created_at'])).".</td> 
        </tr> 
        <tr> 
         <td colspan='2'> 
          <img style=\"float:left;padding: 5px 15px 5px 2px;width: 65px;\" src=\"".$viewrow['gravatar']."\" alt=\"".$viewrow['displayname']."\" title=\"".$viewrow['displayname']."\" /> 
          <div style=\"padding: 8px 5px 2px;\"><span style=\"font-size:1.6em;\">&#8594; </span><b>".$viewrow['subject']."</b></div> 
          <div style=\"padding: 8px 30px 8px 85px;\">".nl2br($viewrow['message'])."<br /></div> 
          <span style=\"float:right;\"> 
           <a href=mail.php?action=compose&toid='".urlencode($viewrow['sender'])."'&subject='RE:+".urlencode($viewrow['subject'])."'&message=".urlencode($viewrow['message']).">Responder</a> | <a href=javascript:confirmDelete('mail.php?action=inbox&deleteid=".$viewid."')>Apagar</a> 
          </span> 
         </td> 
        </tr> 
       </table>"; 

      // mark as read by reciever 
      $query="update mail set mail_status='read' where reciever = '$userid' and mail_id = '$viewid'"; 
      mysql_query($query,$connection) or die(mysql_error()); 
     }     
    }elseif (isset($_GET['action']) && $_GET['action'] == outbox) { ... 

我知道我需要使用後,但如何?

我試過,但無法使它工作。

對不起,我的愚蠢..

+5

使用'POST',而不是'GET'。 – 2013-03-24 08:18:17

+0

如果你有ID,你可能會得到帖子的主題和內容,對吧?一定要從網址中刪除單引號。 – 2013-03-24 08:24:53

+0

我試圖使用POST但沒有成功,也許我的檢索是不正確的。我不知道,IM新到這... – 2013-03-24 08:29:37

回答

0

<a>使用POST不能發送信息的頁面。
但是,您可以使用JavaScript或表單進行操作。

0

您不能隱藏查詢字符串,但是您可以通過POST發送數據,而不是在地址欄中可見。爲此,您需要使用表單提交數據;而Pietroalbini是正確的,你不能使用a元素,你可以風格button看起來相同瑣碎的困難:

<style> 
button { 
    background:none; 
    border: 0; 
    border-bottom:1px solid blue; 
    color: blue; 
    padding:0;   
} 
</style> 

<form action="script.php" method="post"> 
    <input type="text" name="Test"/> 
    <button type="submit">Submit</button> 
</form> 
相關問題