session come mettere l'id utente

searedone

Utente Attivo
11 Giu 2010
508
0
0
Ciao a tutti,

sto cercando di adattare questo script nelle mie pagine riservate, ma non capisco perché vuole a tutti i costi che l'id lo prenda dal require session.php

ma dopo prove e riprove non riesco a capire cosa devo mettere per far si che aggiunga in id_fk l'user_id dI CHI è LOGGATO.

Solitamente uso S_SESSION['user_id']; ma anche se aggiungo questo nel require session non lo prende ??? vi posto un po' di codice se qualcuno mi può' aiutare grazie milleeeee

Pagina dov c'è lo script che serve per postare i mex ( dove c'è require ecc ecc session

PHP:
<?php 
include 'dbc.php';
page_protect();


?>
<html>
<head>
<title>My Account</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<link href="styles.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="5" class="main">
  <tr> 
    <td colspan="3">&nbsp;</td>
  </tr>
  <tr> 
    <td width="160" valign="top">
<?php 
/*********************** MYACCOUNT MENU ****************************
This code shows my account menu only to logged in users. 
Copy this code till END and place it in a new html or php where
you want to show myaccount options. This is only visible to logged in users
*******************************************************************/
if (isset($_SESSION['user_id'])) {?>
<div class="myaccount">
  <p><strong>My Account</strong></p>
  <a href="myaccount.php">My Account</a><br>
  <a href="mysettings.php">Settings</a><br>
    <a href="logout.php">Logout </a>
	
  <p>You can add more links here for users</p></div>
<?php }
if (checkAdmin()) {
/*******************************END**************************/
?>
      <p> <a href="admin.php">Admin CP </a></p>
	  <?php } ?>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p></td>
    <td width="732" valign="top"><p>&nbsp;</p>
      <h3 class="titlehdr">Welcome <?php echo $_SESSION['user_name'];?></h3>  
	  <?php	
      if (isset($_GET['msg'])) {
	  echo "<div class=\"error\">$_GET[msg]</div>";
	  }
	  	  
	  ?>
      <p>This is the my account page</p>
      
      <a href="accetta.php" />Controlla se hai richieste d'amicizia</a>
      
      <br />
      <br />
      
      <br />

	 
	  <form action='cerca.php?ricerca=ok' method='POST'>





  <input type='text' tabindex='15' name='cerca' class='input' size="15" >
  
  <br />
  <br />
<a href="bacheca2.php" />Bacheca</a> | <a href="myprofile.php" />My profile </a>
	 
      </td>
    <td width="196" valign="top"></td>
  </tr>
  <tr> 
    <td colspan="3">&nbsp;</td>
  </tr>
</table>

<?php
error_reporting(0);
include_once 'includes/db.php';
include_once 'includes/functions.php';
include_once 'includes/tolink.php';
include_once 'includes/time_stamp.php';
include_once 'session.php';

$Wall = new Wall_Updates();
$updatesarray=$Wall->Updates($id);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Version 3.0</title>
<link href="css/wall.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
 <script type="text/javascript" src="js/jquery.oembed.js"></script>
 <script type="text/javascript" src="js/wall.js"></script>
</head>
<body>
<div id="wall_container">
<div id="updateboxarea">
<h4>What's up?</h4>
<form method="post" action="">
<textarea cols="30" rows="4" name="update" id="update" maxlength="200" ></textarea>
<br />
<input type="submit"  value=" Update "  id="update_button"  class="update_button"/>
</form>
</div>
<div id='flashmessage'>
<div id="flash" align="left"  ></div>
</div>
<div id="content">

<?php include('load_messages.php'); ?>

</div>

</body>
</html>


session.php

l'originale attribuisce l'id in base al numero che metto manualmente 1 2 3 ecc ecc , io vorrei che prendesse in automatico l'id dell'utente loggato ??

PHP:
<?php
 $id = 1; // User Session ID

//l'originale attribuisce l'id in base al numero che metto manualmente 1 2 3 ecc ecc , io vorrei che prendesse in automatico l'id dell'utente loggato ??
?>
 
risoltoooooo :)

PHP:
<?php
session_start();
$id=$_SESSION['user_id']; // In demo $uid=1 references to 'srinivas' 
?>
 

Discussioni simili