Visualizzazione dei risultati da 1 a 9 su 9

Discussione: [PHP] Problema refresh

  1. #1

    [PHP] Problema refresh

    Ciao a tutti,

    io ho una pagina di update, se faccio click sul tasto aggiorna funziona, il problema sta che devo fare il refresh manuale per vedere l'aggiornamento effettuato, posso fare in modo che subito dopo l'update mi faccia un refresh della pagina???

    Codice PHP:
    if(isset($_GET['submit'])) {
    // header("Refresh:0; URL=admin_center.php?link=updateCall&call_id=". $_GET['call_id']."");
        
    $callsign $_GET['call_callsign'];
        
    $calldate $_GET['call_date'];
        
    $stime $_GET['call_sTime'];
        
    $band $_GET['call_band'];
        
    $mode $_GET['call_mode'];
        
    $power $_GET['call_power'];
        
    $reportout $_GET['call_reportOut'];
        
    $reportin $_GET['call_reportIn'];
        
    $remarks $_GET['call_remarks'];
        
    $user $_GET['call_user'];
        
    $qslin $_GET['call_qslIn'];
        
    $qslout $_GET['call_qslOut'];
        
    $contest $_GET['call_contest'];
        
    mysql_select_db($database_name$conn);
        
    $sql_update "UPDATE tb_contact SET call_callsign = '$callsign', call_date = '$calldate', call_sTime = '$stime', call_band = '$band', call_mode = '$mode', call_power = '$power', call_reportOut = '$reportout', call_reportIn = '$reportin' , call_remarks = '$remarks', call_user = '$user', call_qslIn = '$qslin', call_qslOut = '$qslout', call_contest = '$contest' WHERE tb_contact.call_id = '".$_GET['call_id']."'";
        
    $query_update mysql_query($sql_update) or die (mysql_error());
        } 
    io pensavo con un header refresh ma mi da errore

    Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Xampp\htdocs\xxxxx\admin\admin_center.php:12 ) in C:\Program Files\Xampp\htdocs\xxxxx\admin\inc\updateCall.inc. php on line 22
    PHP THE BEST

  2. #2
    Dipende dal fatto che hai gia' mandato in output del testo nel browser, e per questo l'header() non funziona. Cerca di modificare un po' il codice e spostare il blocco di controllo di $_GET['submit'] ad inizio pagina o comunque fai in modo che quando dai il comando header() non sia stato scritto nulla in output.

  3. #3
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    Togli tutto l'output che hai prima di quel codice... quest'errore è stato trattato almeno 10^9 volte in questo forum.
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  4. #4
    e se usassi javascript sarebbe meglio?

    per esempio esegue la query e poi alla fine mi fa subito un refresh, sarebbe fattibile???
    PHP THE BEST

  5. #5
    Non riesco a capire come fare so che é per quel motivo che non ci deve essere niente prima dell'header ma non so come fare!
    PHP THE BEST

  6. #6
    Originariamente inviato da Sbarboff2005
    Non riesco a capire come fare so che é per quel motivo che non ci deve essere niente prima dell'header ma non so come fare!
    Posta il codice che hai prima di quel controllo e vediamo un po' che si puo' fare...

  7. #7
    Allora questa é una pagina inclusa

    Codice PHP:
    <?php require_once('../connessione/connessione.php'); ?>
    <?php

    if(isset($_GET['submit'])) {

        
    $callsign $_GET['call_callsign'];
        
    $calldate $_GET['call_date'];
        
    $stime $_GET['call_sTime'];
        
    $band $_GET['call_band'];
        
    $mode $_GET['call_mode'];
        
    $power $_GET['call_power'];
        
    $reportout $_GET['call_reportOut'];
        
    $reportin $_GET['call_reportIn'];
        
    $remarks $_GET['call_remarks'];
        
    $user $_GET['call_user'];
        
    $qslin $_GET['call_qslIn'];
        
    $qslout $_GET['call_qslOut'];
        
    $contest $_GET['call_contest'];
        
    mysql_select_db($database_name$conn);
        
    $sql_update "UPDATE tb_contact SET call_callsign = '$callsign', call_date = '$calldate', call_sTime = '$stime', call_band = '$band', call_mode = '$mode', call_power = '$power', call_reportOut = '$reportout', call_reportIn = '$reportin' , call_remarks = '$remarks', call_user = '$user', call_qslIn = '$qslin', call_qslOut = '$qslout', call_contest = '$contest' WHERE tb_contact.call_id = '".$_GET['call_id']."'";
        
    $query_update mysql_query($sql_update) or die (mysql_error());
        
    // header("Refresh:0; URL=admin_center.php?link=updateCall&call_id=". $_GET['call_id']."");
        
    }

    mysql_select_db($database_name$conn);
    $sql "SELECT * FROM tb_contact WHERE call_id = '".$_GET['call_id']."'";
    $query mysql_query($sql) or die (mysql_error());
    $result mysql_fetch_assoc($query);



    ?>

    <div align="center">
      <table width="650" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td></td>
        </tr>
        <tr>
          <td><form id="form1" name="form1" method="get" action="">
            <table width="420" border="0" align="center" cellpadding="0" cellspacing="1">
              <tr>
                <td width="210" height="30" bgcolor="#916600" class="TestoContenuto">Callsign:</td>
                <td width="210" height="30" bgcolor="#916600" class="TestoContenuto">
                    <input name="call_callsign" type="text" id="call_callsign" value="<?php echo $result['call_callsign'];?>" />
                  <input type="hidden" name="call_id" id="hiddenField2" value="<?php echo $result['call_id'];?>" /></td>
              </tr>
              <tr>
                <td height="30" bgcolor="#916600" class="TestoContenuto">Date:</td>
                <td height="30" bgcolor="#916600" class="TestoContenuto">
                    <input name="call_date" type="text" id="call_date" value="<?php echo $result['call_date'];?>" /></td>
              </tr>
              <tr>
                <td height="30" bgcolor="#916600" class="TestoContenuto">Start Time: </td>
                <td height="30" bgcolor="#916600" class="TestoContenuto">
                    <input name="call_sTime" type="text" id="call_sTime" value="<?php echo $result['call_sTime'];?>" /></td>
              </tr>
              <tr>
                <td height="30" bgcolor="#916600" class="TestoContenuto">Band:</td>
                <td height="30" bgcolor="#916600" class="TestoContenuto">
                    <input name="call_band" type="text" id="call_band" value="<?php echo $result['call_band'];?>" /></td>
              </tr>
              <tr>
                <td height="30" bgcolor="#916600" class="TestoContenuto">Mode:</td>
                <td height="30" bgcolor="#916600" class="TestoContenuto">
                    <input name="call_mode" type="text" id="call_mode" value="<?php echo $result['call_mode'];?>" /></td>
              </tr>
              <tr>
                <td height="30" bgcolor="#916600" class="TestoContenuto">Power:</td>
                <td height="30" bgcolor="#916600" class="TestoContenuto">
                    <input name="call_power" type="text" id="call_power" value="<?php echo $result['call_power'];?>" /></td>
              </tr>
              <tr>
                <td height="30" bgcolor="#916600" class="TestoContenuto">Rpt Out: </td>
                <td height="30" bgcolor="#916600" class="TestoContenuto">
                    <input name="call_reportOut" type="text" id="call_reportOut" value="<?php echo $result['call_reportOut'];?>" /></td>
              </tr>
              <tr>
                <td height="30" bgcolor="#916600" class="TestoContenuto">Rpt In:</td>
                <td height="30" bgcolor="#916600" class="TestoContenuto">
                    <input name="call_reportIn" type="text" id="call_reportIn" value="<?php echo $result['call_reportIn'];?>" /></td>
              </tr>
              <tr>
                <td height="30" bgcolor="#916600" class="TestoContenuto">Remarks:</td>
                <td height="30" bgcolor="#916600" class="TestoContenuto">
                    <input name="call_remarks" type="text" id="call_remarks" value="<?php echo $result['call_remarks'];?>" /></td>
              </tr>
              <tr>
                <td height="30" bgcolor="#916600" class="TestoContenuto">User:</td>
                <td height="30" bgcolor="#916600" class="TestoContenuto">
                    <input name="call_user" type="text" id="call_user" value="<?php echo $result['call_user'];?>" /></td>
              </tr>
              <tr>
                <td height="30" bgcolor="#916600" class="TestoContenuto">Qsl In: </td>
                <td height="30" bgcolor="#916600" class="TestoContenuto">
                    <input name="call_qslIn" type="text" id="call_qslIn" value="<?php echo $result['call_qslIn'];?>" /></td>
              </tr>
              <tr>
                <td height="30" bgcolor="#916600" class="TestoContenuto">Qsl Out: </td>
                <td height="30" bgcolor="#916600" class="TestoContenuto">
                    <input name="call_qslOut" type="text" id="call_qslOut" value="<?php echo $result['call_qslOut'];?>" /></td>
              </tr>
              <tr>
                <td height="30" bgcolor="#916600" class="TestoContenuto">Contest:</td>
                <td height="30" bgcolor="#916600" class="TestoContenuto"><input name="call_contest" type="text" id="call_contest" value="<?php echo $result['call_contest'];?>" />
                  <input type="hidden" name="link" id="hiddenField" value="updateCall" /></td>
              </tr>
              <tr>
                <td colspan="2" bgcolor="#916600" class="TestoContenuto"><div align="center">
                  <input type="submit" name="submit" id="submit" value="Aggiorna" />
                </div></td>
              </tr>
              <tr>
                <td colspan="2" bgcolor="#916600" class="TestoContenuto"><div align="center">[url="javascript:history.back()"]Back[/url]</div></td>
              </tr>
            </table>
                </form>      </td>
        </tr>
      </table>
      <?php
    mysql_free_result
    ($query);

    ?>
    </div>
    e questa e la pagina che include lo script sopra

    Codice PHP:
    <?php include"inc/auth.inc.php";?>
    <?php 
    include"inc/logout.inc.php";?>
    <!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>Welcome to hb9fax.ch - Admin Site</title>
    </style>
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <table width="978" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#999A01">
      <tr>
        <td width="150">[img]../image/hb9faxp.jpg[/img]</td>
        <td width="828" bgcolor="#999A01"><div align="center">[img]../image/logo.jpg[/img]</div></td>
      </tr>
      <tr>
        <td></td>
        <td></td>
      </tr>
      <tr>
        <td valign="top"></td>
        <td></td>
      </tr>
      <tr>
        <td valign="top"><?php include"inc/menu.inc.des.php";?></td>
        <td valign="top"><table width="828" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="14">[img]../image/mbordosinistra.jpg[/img]</td>
            <td width="800" bgcolor="#916600"><div align="center" class="TitoloMenu">Pannello di controllo HB9FAX </div></td>
            <td width="14">[img]../image/mbordodestra.jpg[/img]</td>
          </tr>
          <tr>
            <td colspan="3" bgcolor="#9A6600"><table width="826" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="14" bgcolor="#999A01"></td>
                  <td width="650" bgcolor="#999A01"><table width="800" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td></td>
                      </tr>
                    <tr>
                      <td>
                      <?php
                      
    if (isset($_GET['link']) && $_GET['link']!= "" ){
                          if(
    file_exists("inc/" $_GET['link'].".inc.php") && !is_dir("inc/" $_GET['link'].".inc.php")) {
                          include (
    "inc/" $_GET['link'].".inc.php");
                      } else {
                         echo 
    "pagina non trovata";
                     }
                    } else {
                        echo 
    "<span class=\"TestoContenuto\">Grazie per avere usato il pannello di controllo, tra poco sarai reindirizzato alla pagina di login!!</span>";
                    }
                      
    ?>                  </td>
                      </tr>
                    <tr>
                      <td></td>
                    </tr>
                  </table></td>
                  <td width="14" bgcolor="#999A01"></td>
                </tr>

                <tr>
                  <td height="14" colspan="3" bgcolor="#976600">[img]image/1px.gif[/img]</td>
                </tr>
            </table></td>
          </tr>
        </table>    </td>
      </tr>
    </table>
    </body>
    </html>

    praticamente lavoro su una pagina solo e tramite get carico le pagine.
    PHP THE BEST

  8. #8
    Utente di HTML.it
    Registrato dal
    Feb 2002
    Messaggi
    361
    in questi giorni sto sbattendo la testa con gli header anche io.

    Ho notato che non posso eseguire nessun comando prima dell'header , tranne gli include.

    la mia è un ipotesi, ma se scrivessi il codice di visualizzazione in un altra pagina che includi prima dell'header, potrebbe funzionare.

  9. #9
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    Allora, questi sono esempi di cose che fanno deragliare il treno:

    riga vuota:
    codice:
    <?php //qui sopra c'è una riga vuota -> Viene considerato output html
      /* istruzioni PHP
      *
      *
      */
      header("Location: ...); //errore
    output html
    codice:
    <html>
      <body>
      <?php
        header("Location: ...); //c'è output HTML
      ?>
      </body>
    </html>
    echo,print e compagnia bella
    codice:
    <?php
      /* codice php
      *
      *
      echo("Quant'è bello il carosello");
      header("Location: ...); //errore, la riga sopra ha prodotto outpu
    ?>
    In quale categoria ricadi? Sistema di conseguenza. (ossia elimina l'output inutile)
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

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 © 2025 vBulletin Solutions, Inc. All rights reserved.