Problema variabili sessione e ...forse header

k-it

Utente Attivo
14 Ott 2009
30
0
0
Ciao!
Ho un problema che non mi spiego. Ho questa pagina:
PHP:
session_start();
if (!isset($_SESSION['utente'])){
	header('location:index.php?errore=non_autenticato');
	exit;}
$utente=$_SESSION['utente'];
$data_ini = $_POST['data_inizio'];
$data_fin = $_POST['data_fine'];
$data_in = substr($data_ini, 4, 4)."-".substr($data_ini, 2, 2)."-".substr($data_ini, 0, 2)." 00:00:00"
$data_fi = substr($data_fin, 4, 4)."-".substr($data_fin, 2, 2)."-".substr($data_fin, 0, 2)." 23:59:59";
$_SESSION['data_inS'] = $data_in;
$_SESSION['data_fiS'] = $data_fi;
echo $data_in.$data_fi.$_SESSION['data_inS'].$_SESSION['data_fiS'];
dove prendo 2 variabili con due date nel formato ggmmaaaa e hhmm, le trasformo nel formato aaaa-mm-gg hh:mm:ss, cioè il formato timestamp da usare poi nel database, e le metto dentro alle variabili di sessione.
La stampa restituisce correttamente:
2011-07-01 00:00:002011-07-31 23:59:59
2011-07-01 00:00:002011-07-31 23:59:59

Nella pagina successiva (ci arrivo tramite il clic su un form) ho:
PHP:
session_start();
if (!isset($_SESSION['utente'])){
	header('location:index.php?errore=non_autenticato');
	exit;}
$utente=$_SESSION['utente'];
echo $data_in.$data_fi.$_SESSION['data_inS'].$_SESSION['data_fiS'];
qui la stampa mi restituisce:
-- 00:00:00-- 23:59:59
-- 00:00:00-- 23:59:59
sembra come si perdesse le parti che ho messo nella stringa con substr, ma sulla prima pagina me le stampa correttamente!!
e inoltre se lo apro con explorer invece che con firefox funziona!!
Non riesco proprio a trovare una spiegazione?!?
Grazie!!
 

borgo italia

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
4 Feb 2008
16.046
150
63
PR
www.borgo-italia.it
ciao
ho provato e funzia (ie + ff), comunque metti un ; alla riga

$data_in = substr($data_ini, 4, 4)."-".substr($data_ini, 2, 2)."-".substr($data_ini, 0, 2)." 00:00:00";
 

k-it

Utente Attivo
14 Ott 2009
30
0
0
ciao
ho provato e funzia (ie + ff), comunque metti un ; alla riga

$data_in = substr($data_ini, 4, 4)."-".substr($data_ini, 2, 2)."-".substr($data_ini, 0, 2)." 00:00:00";

Ho provato anch'io solo con il codice postato e mi funziona quindi provo a postare il codice completo delle 3 pagine:

fatturare.php

PHP:
<?php // Controllo accesso
session_start();
if (!isset($_SESSION['utente'])){
	header('location:index.php?errore=non_autenticato');
	exit;}
$utente=$_SESSION['utente'];
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Rimorchi</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" media="all" href="skins/aqua/theme.css" title="Aqua" />
<script type="text/javascript" src="calendar.js"></script>
<script type="text/javascript" src="calendar-it.js"></script>

<style type="text/css">
<!--
.Stile13 {font-size: 24px}
.Stile14{
	font-size: 21px;
	color:#000000;
}
.Stile15{
	font-size: 21px;
	color:#FF0000;
	font-family: Verdana, Arial, Helvetica, sans-serif;
}
body {
	background-color: #666666;
	background-image: url();
}
.Stile20 {font-size: 21px; color: #999999; font-family: Verdana, Arial, Helvetica, sans-serif; }
.Stile19 {font-size: 21px;
	color: #666666;
	font-family:Verdana, Arial, Helvetica, sans-serif; 
}
.Stile21 {color: #FFFFFF}
.Stile22 {
	font-size: 24px;
	color: #FF0000;
}
-->
</style>
<script type="text/javascript">
/////CALENDARIO/////
var oldLink = null;
function setActiveStyleSheet(link, title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
  if (oldLink) oldLink.style.fontWeight = 'normal';
  oldLink = link;
  link.style.fontWeight = 'bold';
  return false;
}

// This function gets called when the end-user clicks on some date.
function selected(cal, date) {
  cal.sel.value = date; // just update the date in the input field.
  if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3"))
    cal.callCloseHandler();
}

function closeHandler(cal) {
  cal.hide();                        // hide the calendar
//  cal.destroy();
  _dynarch_popupCalendar = null;
}

function showCalendar(id, format, showsTime, showsOtherMonths) {
  var el = document.getElementById(id);
  if (_dynarch_popupCalendar != null) {
    // we already have some calendar created
    _dynarch_popupCalendar.hide();                 // so we hide it first.
  } else {
    // first-time call, create the calendar.
    var cal = new Calendar(1, null, selected, closeHandler);
    // uncomment the following line to hide the week numbers
    // cal.weekNumbers = false;
    if (typeof showsTime == "string") {
      cal.showsTime = true;
      cal.time24 = (showsTime == "24");
    }
    if (showsOtherMonths) {
      cal.showsOtherMonths = true;
    }
    _dynarch_popupCalendar = cal;                  // remember it in the global var
    cal.setRange(1900, 2070);        // min/max year allowed.
    cal.create();
  }
  _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
  _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
  _dynarch_popupCalendar.sel = el;                 // inform it what input field we use

  _dynarch_popupCalendar.showAtElement(el.nextSibling, "Br");        // show the calendar

  return false;
}

var MINUTE = 60 * 1000;
var HOUR = 60 * MINUTE;
var DAY = 24 * HOUR;
var WEEK = 7 * DAY;

function isDisabled(date) {
  var today = new Date();
  return (Math.abs(date.getTime() - today.getTime()) / DAY) > 10;
}

function flatSelected(cal, date) {
  var el = document.getElementById("preview");
  el.innerHTML = date;
}

function showFlatCalendar() {
  var parent = document.getElementById("display");

  var cal = new Calendar(0, null, flatSelected);

  cal.weekNumbers = false;

  cal.setDisabledHandler(isDisabled);
  cal.setDateFormat("%A, %B %e");

  cal.create(parent);

  cal.show();
}
/////CALENDARIO/////

function controlla(){
	var data_inizio = document.getElementById('data_inizio');
	var data_fine = document.getElementById('data_fine');
	
	if(data_inizio.value == ""){
		alert("CAMPO DATA INIZIALE NON COMPILATO")		
		return false;
	} 
	else if (data_fine.value == "")
	{
		alert("CAMPO DATA FINALE NON COMPILATO")		
		return false;
	}
	return true;
}
</script>
</head>

<body>

<?php
////////INIZIO database////////
require("connessione_database.php");
////////FINE database////////

$dataatt = date("dmY", time());
$data_inizio_mese = strftime ("%d%m%Y",mktime (0,0,0,date(substr($dataatt,2,2))-1,1,date(substr($dataatt,4,4))));
$data_fine_mese = strftime ("%d%m%Y",mktime (23,59,59,date(substr($dataatt,2,2)),0,date(substr($dataatt,4,4))));
?>
<table width="1000" border="0" align="center" style="background-repeat:no-repeat">
  <tr>
    <td height="82" colspan="4">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" align="left" valign="top"><span class="Stile20">DA FATTURARE  </span></td>
    <td colspan="2" align="right" valign="top"><span class="Stile19"><?php echo "$utente";//codice utente?></span></td>
  </tr>
  <tr>
    <td colspan="4">&nbsp;</td>
  </tr>
  <tr>
    <td width="243" height="52" align="center" valign="top"><form name="indietro" method="post" action="fatture.php">
		<input type="image" name="indietro" class="Stile14" value="INDIETRO" src="imm/bottone_indietro_0.gif" onmouseout="this.src='imm/bottone_indietro_0.gif'" onmouseover="this.src='imm/bottone_indietro_1.gif'" onMouseDown="this.src='imm/bottone_indietro_2.gif'">
    </form></td>
    <td width="243" height="52" align="left" valign="top"><form name="indietro" method="post" action="menu.php">
        <input type="image" name="menu" class="Stile14" value="MENU" src="imm/bottone_menu_0.gif" onMouseOut="this.src='imm/bottone_menu_0.gif'" onMouseOver="this.src='imm/bottone_menu_1.gif'" onMouseDown="this.src='imm/bottone_menu_2.gif'">
    </form></td>
    <td width="250">&nbsp;</td>
    <td width="246">&nbsp;</td>
  </tr>
  <tr>
    <td height="66" colspan="2"><form name="form1" method="post" onSubmit="return controlla()" action="fatturare1.php">
	<table width="447" border="0">
      <tr>
        <td colspan="2" class="Stile20">PERIODO DA FATTURARE</td>
        </tr>
      <tr>
        <td width="70" class="Stile20">DAL</td>
        <td width="367"><input id="data_inizio" type="text" name="data_inizio" class="Stile13" value="<?php echo $data_inizio_mese;?>"><input type="reset" class="Stile14" value="..." onClick="return showCalendar('data_inizio', '%d%m%Y');"></td>
        </tr>
      <tr>
        <td class="Stile20">AL </td>
        <td><input id="data_fine" name="data_fine" type="text" class="Stile13" value="<?php echo $data_fine_mese;?>"><input type="reset" class="Stile14" value="..." onClick="return showCalendar('data_fine', '%d%m%Y');"></td>
        </tr>
      <tr>
        <td>&nbsp;</td>
        <td><input type="image" name="ok" class="Stile14" value="OK" src="imm/bottone_ok_0.gif" onmouseout="this.src='imm/bottone_ok_0.gif'" onmouseover="this.src='imm/bottone_ok_1.gif'" onMouseDown="this.src='imm/bottone_ok_2.gif'"></td>
        </tr>
    </table>
    </form></td>
    <td height="66" colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="4">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="4">&nbsp;</td>
  </tr>
</table>

</body>
</html>
<?php //mysql_free_result($risultato); ?>

fatturare1.php

PHP:
<?php // Controllo accesso
session_start();
if (!isset($_SESSION['utente'])){
	header('location:index.php?errore=non_autenticato');
	exit;}
$utente=$_SESSION['utente'];
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Rimorchi</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
<!--
.Stile14{
	font-size: 21px;
	color:#000000;
}
.Stile15{
	font-size: 21px;
	color:#FF0000;
	font-family: Verdana, Arial, Helvetica, sans-serif;
}
body {
	background-color: #666666;
	background-image: url();
}
.Stile20 {font-size: 21px; color: #999999; font-family: Verdana, Arial, Helvetica, sans-serif; }
.Stile19 {font-size: 21px;
	color: #666666;
	font-family:Verdana, Arial, Helvetica, sans-serif; 
}
.Stile21 {color: #FFFFFF}
.Stile22 {
	font-size: 24px;
	color: #FF0000;
}
.Stile13 {font-size: 24px}
-->
</style>
</head>

<body>

<?php
////////INIZIO database////////
require("connessione_database.php");
////////FINE database////////

$data_ini = $_POST['data_inizio'];
$data_fin = $_POST['data_fine'];
$data_in = substr($data_ini, 4, 4)."-".substr($data_ini, 2, 2)."-".substr($data_ini, 0, 2)." 00:00:00";
$data_fi = substr($data_fin, 4, 4)."-".substr($data_fin, 2, 2)."-".substr($data_fin, 0, 2)." 23:59:59";

$_SESSION['data_inS'] = $data_in;
$_SESSION['data_fiS'] = $data_fi;
$risultato = mysql_query ("(SELECT codice_cliente_motrice AS codice FROM storico_client WHERE (codice_storico = 'MOTRICE' OR codice_storico = 'SOLO_MOTRICE' OR codice_storico = 'AUTOBUS') AND codice_cliente_motrice IS NOT NULL AND codice_cliente_motrice!='' AND targa_motrice_ing!='RALLA' AND num_fattura = '0' AND pagato = '0' AND importo_sosta!='0.00' AND data_uscTS > '$data_in' AND data_uscTS < '$data_fi') UNION (SELECT codice_cliente_rimorchio AS codice FROM storico_client WHERE (codice_storico = 'RIMORCHIO_MOTRICE' OR codice_storico = 'RIMORCHIO_RALLA' OR codice_storico = 'CARICO_ECCEZIONALE_MOTRICE' OR codice_storico = 'CARICO_ECCEZIONALE_RALLA') AND codice_cliente_rimorchio IS NOT NULL AND codice_cliente_rimorchio!='' AND targa_rimorchio!='RALLA' AND num_fattura = '0' AND pagato = '0' AND importo_sosta!='0.00' AND data_uscTS > '$data_in' AND data_uscTS < '$data_fi') UNION (SELECT codice_cliente_rimorchio AS codice FROM storico_client WHERE (codice_storico = 'ABBONAMENTO' ) AND targa_rimorchio!='RALLA' AND num_fattura = '0' AND pagato = '0' AND importo_sosta!='0.00' AND data_uscTS > '$data_in' AND data_uscTS < '$data_fi') ORDER BY codice"); 
$righe = mysql_num_rows($risultato);


$risultato1 = mysql_query ("SELECT * FROM info"); 
$righe1 = mysql_num_rows($risultato1);
if ($righe1 > 0){
	 $riga1 = mysql_fetch_row($risultato1);
	 $ultima_fattura = $riga1[1];
	 $intestazioner1 = $riga1[3];
	 $intestazioner2 = $riga1[4];
	 $intestazioner3 = $riga1[5];
	 $intestazioner4 = $riga1[6];
	 $intestazioner5 = $riga1[7];
	 $intestazioner6 = $riga1[8];
	 $iva = $riga1[9];
}

$num_fattura_iniziale = $ultima_fattura+1;

?>
<table width="1000" border="0" align="center" style="background-repeat:no-repeat">
  <tr>
    <td height="82" colspan="4">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" align="left" valign="top"><span class="Stile20">DA FATTURARE  </span></td>
    <td colspan="2" align="right" valign="top"><span class="Stile19"><?php echo "$utente";//codice utente?></span></td>
  </tr>
  <tr>
    <td colspan="4">&nbsp;</td>
  </tr>
  <tr>
    <td width="243" height="52" align="center" valign="top"><form name="indietro" method="post" action="fatturare.php">
		<input type="image" name="indietro" class="Stile14" value="INDIETRO" src="imm/bottone_indietro_0.gif" onmouseout="this.src='imm/bottone_indietro_0.gif'" onmouseover="this.src='imm/bottone_indietro_1.gif'" onMouseDown="this.src='imm/bottone_indietro_2.gif'">
    </form></td>
    <td width="243" height="52" align="left" valign="top"><form name="indietro" method="post" action="menu.php">
        <input type="image" name="menu" class="Stile14" value="MENU" src="imm/bottone_menu_0.gif" onMouseOut="this.src='imm/bottone_menu_0.gif'" onMouseOver="this.src='imm/bottone_menu_1.gif'" onMouseDown="this.src='imm/bottone_menu_2.gif'">
    </form></td>
    <td width="250">&nbsp;</td>
    <td width="246">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="4">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="4"><form name="form" method="post" action="fatturare2.php"><table width="992" border="0">
      <tr>
        <td class="Stile20">NUMERO FATTURA INIZIALE          </td>
      </tr>
      <tr>
        <td class="Stile20"><input id="num_fattura_iniziale" type="text" name="num_fattura_iniziale" class="Stile13" value="<?php echo $num_fattura_iniziale;?>"></td>
      </tr>
      <tr>
        <td class="Stile20">LISTA CLIENTI DA FATTURARE</span></td>
      </tr>
      <?php if ($righe > 0) {
				for ($i=0; $i<$righe; $i++){
   					$riga = mysql_fetch_row($risultato); 
					?>
      <tr>
        <td colspan="2" class="Stile20 Stile21">
		<input type="checkbox" name="<?php echo "codice_clienteL[$i]";?>" value="<?php echo "$riga[0]";?>" checked="checked">
          &nbsp;<?php echo html_entity_decode($riga[0]); 
		   ?>          </td>
      </tr>
      <?php
				}
			} else{?>
      <tr>
        <td colspan="2" class="Stile20 Stile21 Stile22">NIENTE DA FATTURARE</td>
      </tr>
      <?php } ?>
      <tr>
        <td colspan="2" class="Stile15"><?php if ($righe > 0) {?><input type="image" name="ok2" class="Stile14" value="OK" src="imm/bottone_ok_0.gif" onmouseout="this.src='imm/bottone_ok_0.gif'" onmouseover="this.src='imm/bottone_ok_1.gif'" onMouseDown="this.src='imm/bottone_ok_2.gif'"><?php } else {echo "&nbsp;";}?></td>
      </tr>
    </table>
    </form></td>
  </tr>
  <tr>
    <td colspan="4">&nbsp;</td>
  </tr>
</table>

</body>
</html>
<?php 
//echo $data_in.$data_fi."<br>".$_SESSION['data_inS'].$_SESSION['data_fiS'];

mysql_free_result($risultato); ?>

fatturare2.php

PHP:
<?php // Controllo accesso
session_start();
if (!isset($_SESSION['utente'])){
	header('location:index.php?errore=non_autenticato');
	exit;}
$utente=$_SESSION['utente'];
////////INIZIO database////////
require("connessione_database.php");
////////FINE database////////
echo $data_in.$data_fi.$_SESSION['data_inS'].$_SESSION['data_fiS'];

$_SESSION['codice_clienteLS'] = $_POST['codice_clienteL'];
$_SESSION['num_fattura_inizialeS'] = $_POST['num_fattura_iniziale'];
header("location:fatturare3.php");
?>

su fatturare2.php non lo stampa correttamente... :(
 

k-it

Utente Attivo
14 Ott 2009
30
0
0
Ho trovato!!
negli stili avevo:

body {
background-color: #666666;
background-image: url();
}

cancellndo la riga "background-image: url();" funziona!
non so cosa sta ad indicare url() perchè avevo l'immagine di sfondo che poi ho tolto ed è rimasto solo il colore, mah....!!
Grazie!!!
Ciao
 

Eliox

Utente Attivo
25 Feb 2005
4.390
3
0
Non sono un designer ma "background-image: url()" espresso così così non significa niente, manca il parametro relativo all'immagine di sfondo.
 

borgo italia

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
4 Feb 2008
16.046
150
63
PR
www.borgo-italia.it
ciao
avresti dovuto dirgli

background-image:url(mia_cartella/immagine.png);/* o jpg o gif */

p.s. @eliox
scala di uno il contatore:angel:
 

k-it

Utente Attivo
14 Ott 2009
30
0
0
Probabilmente l'ha scritto così dreamweaver quando ho tolto l'immagine di sfondo dalle proprietà, comunque il problema non era per lo sfondo ma mi incasinava il resto come ho scritto sopra.
Comunque si può chiudere la discussione
Saluti!
 
Discussioni simili
Autore Titolo Forum Risposte Data
K [PHP] Problema con variabili concatenate. PHP 1
N Problema passaggio variabili tra pagine PHP 4
A Problema con getCurrentPosition e passaggio variabili da javascript a PHP Javascript 3
ANDREA20 problema variabili PHP 4
R Problema passaggio variabili POST PHP 0
E php problema incremento e decremento di 2 variabili con click da pulsante PHP 0
S Problema Variabili Javascript 0
M Problema con aggiornamento variabili da web server con javascript Javascript 1
G Problema IF con 6 variabili PHP 1
V Problema con riporto variabili PHP 2
X [Wordpress- Woocommerce] Problema con numero prodotti variabili WordPress 2
L problema login con variabili PHP 7
P problema: dichiarare e richiamare variabili all'interno di una classe PHP 2
N Problema gestione variabili PHP 5
M problema scope variabili chiamata ajax Javascript 2
J problema passaggio di variabili Classic ASP 0
S problema con delle variabili PHP 6
I problema variabili Flash 0
D Problema Passaggio variabili Classic ASP 2
C problema include e variabili PHP 5
N [problema] ComboBox e variabili Flash 0
S Flash & PHP - Problema passaggio variabili! Flash 1
M problema con variabili Flash 0
M Problema passaggio variabili in asp Classic ASP 2
R problema con le variabili e i notice.... PHP 1
I Sto progettando nuovi siti utilizzando bootstrap e devo dire funziona bene, l'unico problema e la maschera -moz- HTML e CSS 0
K Problema form update PHP 2
O problema con dvr dahua xvr5116 IP Cam e Videosorveglianza 0
S Problema nel ciclare un json Javascript 0
G Problema con Xampp Web Server 1
andrea barletta Problema con miniature comandi Photoshop 0
I problema con alice Posta Elettronica 0
K Problema Inner join PHP 1
F firefox problema http Linux e Software 0
N Problema con position absolute e overflow HTML e CSS 4
E Problema jquery Success jQuery 2
L Problema con inner join PHP 11
K [php] Problema con inner join PHP 4
E problema selezione sfumata Photoshop 2
A Problema filtro fluidifica Photoshop Photoshop 1
H Problema Bordi Scontorno Photoshop 1
O problema con query PHP 4
R Problema installazione Realtek WiFi USB rtl8821 Reti LAN e Wireless 0
I problema con 2 account Posta Elettronica 1
L problema collegamento file css con html HTML e CSS 1
Y Problema percorso file in rete PHP 1
N Problema SEO "L'URL non si trova su Google" SEO e Posizionamento 4
E Problema accesso a file con app sviluppata con MIT APP INVENTOR 2 Sviluppo app per Android 0
P Problema acquisizione clienti Webdesign e Grafica 1
F NetBeans problema creazione progetto Java Windows e Software 0

Discussioni simili