Visualizzazione dei risultati da 1 a 6 su 6
  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2009
    Messaggi
    46

    Problema variabili sessione e ...forse header

    Ciao!
    Ho un problema che non mi spiego. Ho questa pagina:
    Codice 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_ini44)."-".substr($data_ini22)."-".substr($data_ini02)." 00:00:00"
    $data_fi substr($data_fin44)."-".substr($data_fin22)."-".substr($data_fin02)." 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:
    Codice 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!!

  2. #2
    Nel secondo script da dove prendi $data_in e $data_fi?
    "Mai discutere con un idiota. Ti trascina al suo livello e ti batte con l'esperienza." (Oscar Wilde)

  3. #3
    Utente di HTML.it
    Registrato dal
    Nov 2009
    Messaggi
    46
    Originariamente inviato da satifal
    Nel secondo script da dove prendi $data_in e $data_fi?
    non li considerare, mi sono rimasti nell'echo ma non essendo inizializzati non li stampa
    la cosa strana è che nella variabile di sessione sembra inserirci solo una parte di quello che gli passo nella prima pagina, cioè prende solo le parti che gli passo come stringa tra "" quelle che gli passo con substr si perdono, ma, ancora più strano su explorer va bene!

  4. #4
    Qui manca un ;

    Codice PHP:
    ...
    $data_in substr($data_ini44)."-".substr($data_ini22)."-".substr($data_ini02)." 00:00:00"
    ... 
    "Mai discutere con un idiota. Ti trascina al suo livello e ti batte con l'esperienza." (Oscar Wilde)

  5. #5
    Utente di HTML.it
    Registrato dal
    Nov 2009
    Messaggi
    46
    Originariamente inviato da satifal
    Qui manca un ;

    Codice PHP:
    ...
    $data_in substr($data_ini44)."-".substr($data_ini22)."-".substr($data_ini02)." 00:00:00"
    ... 
    Il ; non mancava sull'originale
    Ho provato solo con il codice postato e mi funziona quindi provo a postare il codice completo delle 3 pagine:

    fatturare.php

    Codice 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>

    <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"></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"></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"></td>
        <td width="246"></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></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"></td>
      </tr>
      <tr>
        <td colspan="4"></td>
      </tr>
      <tr>
        <td colspan="4"></td>
      </tr>
    </table>

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

    Codice 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">


    </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_ini44)."-".substr($data_ini22)."-".substr($data_ini02)." 00:00:00";
    $data_fi substr($data_fin44)."-".substr($data_fin22)."-".substr($data_fin02)." 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"></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"></td>
      </tr>
      <tr>
        <td colspan="4"></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">
              <?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 "";}?></td>
          </tr>
        </table>
        </form></td>
      </tr>
      <tr>
        <td colspan="4"></td>
      </tr>
    </table>

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

    mysql_free_result(
    $risultato); ?>
    fatturare2.php

    Codice 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...

  6. #6
    Utente di HTML.it
    Registrato dal
    Nov 2009
    Messaggi
    46
    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

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.