Un saluto agli amici del forum, vi spiego brevissimamente il mio problema.
Ho 3 pagine .php
login.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ".w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=".w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Accesso</title>
<link rel="stylesheet" type="text/css" href="/script/ire/css/ire.css" >
</head>
<body>
<div id="contenitore" >
<form name="login" method="post" action="anagrafica.php">
<label>Id Utente
<input name="id" type="text" id="id" />
<input name="Invia" type="submit" />
</label>
</form>
</div>
</body>
</html>
```che altro non è che un semplice form dove l'utente inserisce il proprio id che tramite il campo POST viene ricevuto dalla pagina
anagrafica.php
<?php require_once('Connections/conn.php'); ?>
<?php $id = $_POST['id']; ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_conn, $conn);
$query_ire_db = "SELECT * FROM accounts INNER JOIN accounts_cstm ON accounts.id = accounts_cstm.id_c INNER JOIN accounts_opportunities ON accounts.id = accounts_opportunities.account_id AND accounts_cstm.id_c = accounts_opportunities.account_id INNER JOIN opportunities_cstm ON accounts_opportunities.opportunity_id = opportunities_cstm.id_c WHERE accounts.id ='$id'";
$ire_db = mysql_query($query_ire_db, $conn) or die(mysql_error());
$row_ire_db = mysql_fetch_assoc($ire_db);
$totalRows_ire_db = mysql_num_rows($ire_db);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ".w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=".w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Anagrafica</title>
<link rel="stylesheet" type="text/css" href="/script/ire/css/ire.css" />
</head>
<body>
<div id="contenitore">
<div id="header_menu"><a href="anagrafica.php" tabindex="10" title="Anagrafica">Anagrafica</a> | <a href="info_adesione.php" tabindex="20" title="Info Adesione">Info Adesione</a> | <a href="info_quota_associativa.php" tabindex="30" title="Info Quota Associativa">Info Quota Associativa</a> |<a href="info_kit_associati.php" tabindex="40" title="Info Kit Associati"> Info Kit Associati</a> | <a href="documentazione_allegata.php" tabindex="50" title="Documentazione Allegata">Documentazione Allegata</a> | <a href="opportunita.php" tabindex="60" title="Opportunità">Opportunità</a> | <a href="logout.php" tabindex="70" title="Logout">Logout</a></div>
<div id="header_anagrafica">Anagrafica</div>
<div id="tabella">
<table width="420" border="1">
<tr>
<td width="183">id</td>
<td width="221"><?php echo $row_ire_db['id']; ?></td>
</tr>
</table>
</div>
<div id="tabella">
<table width="420" border="1">
<tr>
<td width="183">Ragione Sociale</td>
<td width="221"><?php echo $row_ire_db['name']; ?></td>
</tr>
</table>
</div>
<div id="tabella">
<table width="420" border="1">
<tr>
<td width="183">Data Firma Contratto</td>
<td width="221"><?php echo $row_ire_db['data_firma_c']; ?></td>
</tr>
</table>
</div>
<div id="tabella">
<table width="420" border="1">
<tr>
<td width="183">Stato Adesione</td>
<td width="221"><?php echo $row_ire_db['stato_adesione_c']; ?></td>
</tr>
</table>
</div>
<div id="tabella">
<table width="420" border="1">
<tr>
<td width="183">Indirizzo Sede Legale</td>
<td width="221"><?php echo $row_ire_db['billing_address_street']; ?></td>
</tr>
</table>
</div>
<div id="tabella">
<table width="420" border="1">
<tr>
<td width="183">Indirizzo Comunicazioni</td>
<td width="221">"da definire"</td>
</tr>
</table>
</div>
<div id="tabella">
<table width="420" border="1">
<tr>
<td width="183">Partita IVA</td>
<td width="221"><?php echo $row_ire_db['piva_c']; ?></td>
</tr>
</table>
</div>
<div id="tabella">
<table width="420" border="1">
<tr>
<td width="183">Codice Fiscale</td>
<td width="221"><?php echo $row_ire_db['codice_fiscale_c']; ?></td>
</tr>
</table>
</div>
<div id="tabella">
<table width="420" border="1">
<tr>
<td width="183">Telefono Ufficio</td>
<td width="221"><?php echo $row_ire_db['phone_office']; ?></td>
</tr>
</table>
</div>
</div>
</body>
</html>
<?php
mysql_free_result($ire_db);
?>
Adesso il mio problema è quello di fare in modo che venga popolata anche la pagina info_adesione.php che contiene ulteriori dati riguardanti sempre lo stesso id, solo che appena mi sposto tra le pagine perdo i dati, ho provato diversi modi per implementare le sessioni ma ho fallito su tutti i fronti.
Vi posto il codice della pagina info_adesione.php nella speranza di risolvere il problema con il vostro aiuto.
<?php require_once('Connections/conn.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_conn, $conn);
$query_ire_db = "SELECT * FROM accounts INNER JOIN accounts_cstm ON accounts.id = accounts_cstm.id_c INNER JOIN accounts_opportunities ON accounts.id = accounts_opportunities.account_id AND accounts_cstm.id_c = accounts_opportunities.account_id INNER JOIN opportunities_cstm ON accounts_opportunities.opportunity_id = opportunities_cstm.id_c WHERE accounts.id ='$id'";
$ire_db = mysql_query($query_ire_db, $conn) or die(mysql_error());
$row_ire_db = mysql_fetch_assoc($ire_db);
$totalRows_ire_db = mysql_num_rows($ire_db);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ".w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=".w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Info Adesione</title>
<link rel="stylesheet" type="text/css" href="/script/ire/css/ire.css" >
</head>
<body>
<div id="contenitore">
<div id="header_menu"><a href="anagrafica.php" tabindex="10" title="Anagrafica">Anagrafica</a> | <a href="info_adesione.php" tabindex="20" title="Info Adesione">Info Adesione</a> | <a href="info_quota_associativa.php" tabindex="30" title="Info Quota Associativa">Info Quota Associativa</a> |<a href="info_kit_associati.php" tabindex="40" title="Info Kit Associati"> Info Kit Associati</a> | <a href="documentazione_allegata.php" tabindex="50" title="Documentazione Allegata">Documentazione Allegata</a> | <a href="opportunita.php" tabindex="60" title="Opportunità">Opportunità</a>| <a href="logout.php" tabindex="70" title="Logout">Logout</a></div>
<div id="header_anagrafica">Info Adesione</div>
<div id="tabella">
<table width="420" border="1">
<tr>
<td width="183">Codice Associato</td>
<td width="221"><?php echo $row_ire_db['codice_associato_c']; ?></td>
</tr>
</table>
</div>
<div id="tabella">
<table width="420" border="1">
<tr>
<td width="183">Data Firma Contratto</td>
<td width="221"><?php echo $row_ire_db['data_firma_c']; ?></td>
</tr>
</table>
</div>
<div id="tabella">
<table width="420" border="1">
<tr>
<td width="183">Data Consegna</td>
<td width="221"><?php echo $row_ire_db['data_consegna_c']; ?></td>
</tr>
</table>
</div>
<div id="tabella">
<table width="420" border="1">
<tr>
<td width="183">Distinta Elettronica</td>
<td width="221"> </td>
</tr>
</table>
</div>
<div id="tabella">
<table width="420" border="1">
<tr>
<td width="183">Risparmio Ottenuto</td>
<td width="221"> </td>
</tr>
</table>
</div>
</div>
</body>
</html>
Confido in voi :x
P.S
Mi ero creato, grazie all'aiuto di un amico anche una pagina d'appoggio gestione_login.php ma non sono mai riuscito a implementarla
<?php
// Effettua il controllo se non è stata passata una variabile id tramite POST
// Se la condizione è Vera effettua il reindirizzamento alla pagina login
if(!isset($_POST['id']))
header('location:login.php');
else {
session_set_cookie_params('600'); // 10 minutes.
//session start
session_start();
//connessione db
include("Connections/conn_locale.php");
$id = $_POST['id'];
mysql_select_db($database_conn, $conn);
//$query_ire_db = "Select * from accounts WHERE id='$id'";
$query_ire_db = "SELECT * FROM accounts INNER JOIN accounts_cstm ON accounts.id = accounts_cstm.id_c INNER JOIN accounts_opportunities ON accounts.id = accounts_opportunities.account_id AND accounts_cstm.id_c = accounts_opportunities.account_id INNER JOIN opportunities_cstm ON accounts_opportunities.opportunity_id = opportunities_cstm.id_c WHERE accounts.id ='$id'";
$ire_db = mysql_query($query_ire_db, $conn) or die(mysql_error());
$row_ire_db = mysql_fetch_assoc($ire_db);
$totalRows_ire_db = mysql_num_rows($ire_db);
if($totalRows_ire_db)
{
echo "Login effettuato con successo!!";
$_SESSION['id'] = $row_ire_db['id'];
header('location:anagrafica.php');
}
else header('location:login_failed.php');
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
Thanks !