2017-01-25 18 views
0

我想顯示來自一個especific用戶的信息,並且我有一個$ _session 工作正常,但有一個表,在這種情況下,我不想使用 表我必須使用CSS div,當我測試它時,告訴我這個 錯誤注意:未定義索引:當這個「usuario」科莫 從登錄索引文件

<?php 


require("conection/connect.php"); 

session_start(); 


$sql="SELECT stu_id, 
    f_name, 
    s_name, 
    l_name, 
    sl_name, 
    gender, 
    dob, 
    pob, 
    address, 
    phone, 
    email, 
    note 
    from tblstudents 
    where stu_id"; //i want to use a where stu_id='".$_SESSION['usuario']."'"; but it is not working show me Notice: Undefined index: usuario in C:\xampp\htdocs\studentskin\infostudent.php on line 2 
    $infostudent=mysql_query($sql);  // but when I did a test with where stu_id"; it is showing me the all users that I have on the table 


?> 

<html> 
<head><center><h3>Alumno</h3></center></head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>::. Secundaria 10 .::</title>     
<link href="css/backgroundcolor.css" /> 
<body> 
<center> 
<?php 

while ($tblstudents=mysql_fetch_assoc($infostudent)){ 

     echo $tblstudents['stu_id']. 
     "<div>".$tblstudents['f_name']." ".$tblstudents['s_name']." ".$tblstudents['l_name']." ".$tblstudents['sl_name']."</div>"; 
     echo""; 
     }  
?> 

//我想用$ _SESSION只是登錄我並告訴我信息我已記錄的所有信息

+0

請問您可以發佈整個代碼嗎? –

+0

您可以粘貼$ _SESSION定義的代碼嗎? – Jerry

+0

if(isset($ _ POST ['btn_log'])){ \t \t $ uname = $ _ POST ['unametxt']; \t \t $ pwd = $ _ POST ['pwdtxt']; \t \t $ _SESSION ['usuario'] = $ _POST ['unametxt']; \t \t \t \t $ _SESSION ['password'] = $ _POST ['pwdtxt']; \t \t \t \t \t \t \t \t $ _SESSION [ 'usuario'] = $ _POST [ 'unametxt']; \t \t \t \t \t \t $ _SESSION ['password'] = $ _POST ['pwdtxt']; \t \t $ SQL =請求mysql_query(「SELECT * FROM tbluser \t \t \t \t \t \t \t \t其中username = '$ UNAME' 和密碼= '$ PWD' \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t「); –

回答

0
<?php 
require("conection/connect.php"); 

session_start(); 

$sql="SELECT 
    `stu_id`, 
    `f_name`, 
    `s_name`, 
    `l_name`, 
    `sl_name`, 
    `gender`, 
    `dob`, 
    `pob`, 
    `address`, 
    `phone`, 
    `email`, 
    `note` 
    from tblstudents 
    where stu_id='".$_SESSION['usuario']."'"; 

    $records=mysql_query($sql); 

?> 




<html> 
<head><h1>Informacion</h1></head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>::. Secundaria 10 .::</title>     
<body> 

<div> 
<center> 

<?php 

while ($tblstudents=mysql_fetch_assoc($records)){ 


echo "<div>".$tblstudents['stu_id']."<div>"; 
echo "<div>".$tblstudents['s_name']." ".$tblstudents['s_name']." ".$tblstudents['l_name']." ".$tblstudents['sl_name']."</div>"; 
echo "<div>".$tblstudents['gender']."</div>"; 
echo "<div>".$tblstudents['dob']."</div>"; 
echo "<div>".$tblstudents['pob']."</div>"; 
echo "<div>".$tblstudents['address']."</div>"; 
echo "<div>".$tblstudents['phone']."</div>"; 
echo "<div>".$tblstudents['email']."</div>"; 
echo "<div>".$tblstudents['note']."</div>"; 




}  

?></center> 
</body> 
</div> 
</html> 
+1

請不要發佈這個答案,它不是一個答案 - 編輯問題,如果你有更新。如果你想要回答這個問題,那就解釋一下爲什麼 – ADyson

相關問題