2013-12-17 115 views
0

請給我一些想法熱點,以獲得身份證號碼在我的情況。ID的建議獲取點擊按鈕

我在一個文件中有這個腳本。我需要的是發送一個我按下的用戶uder的ID號碼按鈕follow。這個ID我們可以在$row['id']找到,但我不知道如何將它發送到另一個腳本lib/follow.php

<?php 
      $users = mysql_query("SELECT * FROM 111212_users"); 
      while($row = mysql_fetch_array($users)){ 
//    $_SESSION['f_id'] = $row['id']; 
       echo "------------------------------------"; 
       echo "<li>Full name: ".$row['name']."</li><li>Nickname: " .$row['nickname']."</li><li><form action='lib/follow.php' method='get'><input type='submit' name='follow' value='Follow'><form></li>"; 
      } 
      ?> 

lib/follow.php腳本。我需要發送ID變量$其次,如果它已被送往

<?php 
session_start(); 
include "connect.php"; 
if(isset($_GET["follow"])){ 
    if(isset($_SESSION["f_id"])){ 
     $followed = $_SESSION["f_id"]; 
     $follower = $_SESSION['userId']; 
     $sql = "INSERT INTO 111212_follow (followed,follower) VALUES ('$followed','$follower')"; 
     if (!mysql_query($sql)){ 
      die('Error: ' . mysql_error()); 
     } 
     header('Location: ../main.php'); 

    } 
} 

?> 
+0

什麼是你所得到的問題? –

+0

Steve

+0

如果我正在使用會話,我會收到錯誤的ID至$。它等於$追隨者ID – vladja

回答

0

可以使用錨標記來獲取值

echo "<li><a href="lib/follow.php?id=$row['id']">Full name: ".$row['name']."</a></li>" 
+0

毫米,沒有工作.... =(也許我做了一些錯誤 – vladja

0
send using "<form action='lib/follow.php?followed=".$row['id']."' method='get'> 

Receive using $followed = $_GET['followed']; 

Else 
Any how ur getting using session 

$followed = $_SESSION["f_id"]; 

set the id in session 

session_start(); 
// store/set session data 
$_SESSION['f_id']=$row['id']; 
+0

如何在會話中設置ID?不明白 – vladja