Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it
    Registrato dal
    Sep 2006
    Messaggi
    81

    Insert Record E Collegamento Ipertestuale

    Salve spero possiate aiutarmi. sto costruendo delle pagine in php che mi consentano di consegnare le formazioni del fantacalcio on line e visualizzarle direttamente sul web. In pratica ho fatto:

    - pagina di login e password (ok)
    - pagina che in base alla squadra selezionata mi stampa a video la rosa dei 25 giocatori in dei menu a tendina tramite recordset (ok)

    ora voglio fare che selezionati i giocatori da mandare in campo premendo il tasto invio mi venga aggiornato il database "formazione" con insert record (ok) e dopo in automatico mi vada in una pagina chiamata formazioneconsegnata.php ...e quest'ultima cosa non la fa.
    Ho preso il modulo di dreamweaver di inert record e alla voce "after inserting go to" ho selezionato l pagina che vorrei ma non ci va dopo aver premuto il tasto invia mi aggiorna il database ma mi resta sulla pagina di gestione della formazione e mi da questo errore

    Warning: Cannot modify header information - headers already sent by (output started at g:\programmi\easyphp1-8\www\fanta.php:3) in g:\programmi\easyphp1-8\www\fanta.php on line 48


    Questo è il codice:

    <?php require_once('Connections/fanta.php'); ?>
    <?php require_once('Connections/fanta.php'); ?>
    <?php
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
    $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
    }

    $editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
    if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
    $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
    }

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "formaz")) {
    $insertSQL = sprintf("INSERT INTO formazione (cod_giorn, player, team1) VALUES (%s, %s, %s)",
    GetSQLValueString($_POST['giornata'], "int"),
    GetSQLValueString($_POST['2'], "text"),
    GetSQLValueString($_POST['nomes'], "text"));

    mysql_select_db($database_fanta, $fanta);
    $Result1 = mysql_query($insertSQL, $fanta) or die(mysql_error());

    $insertGoTo = "preview.php";
    if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
    }
    header(sprintf("Location: %s", $insertGoTo));
    }

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "formaz")) {
    $insertSQL = sprintf("INSERT INTO formazione (cod_giorn, player, team1) VALUES (%s, %s, %s)",
    GetSQLValueString($_POST['giornata'], "int"),
    GetSQLValueString($_POST['1'], "text"),
    GetSQLValueString($_POST['nomes'], "text"));

    mysql_select_db($database_fanta, $fanta);
    $Result1 = mysql_query($insertSQL, $fanta) or die(mysql_error());

    $insertGoTo = "preview.php";
    if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
    }
    header(sprintf("Location: %s", $insertGoTo));
    }

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "formaz")) {
    $insertSQL = sprintf("INSERT INTO formazione (cod_giorn, player, team1) VALUES (%s, %s, %s)",
    GetSQLValueString($_POST['giornata'], "int"),
    GetSQLValueString($_POST['3'], "text"),
    GetSQLValueString($_POST['nomes'], "text"));

    mysql_select_db($database_fanta, $fanta);
    $Result1 = mysql_query($insertSQL, $fanta) or die(mysql_error());

    $insertGoTo = "preview.php";
    if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
    }
    header(sprintf("Location: %s", $insertGoTo));
    }

    $maxRows_Recordset4 = 25;
    $pageNum_Recordset4 = 0;
    if (isset($_GET['pageNum_Recordset4'])) {
    $pageNum_Recordset4 = $_GET['pageNum_Recordset4'];
    }
    $startRow_Recordset4 = $pageNum_Recordset4 * $maxRows_Recordset4;

    $use_Recordset4 = "-1";
    if (isset($_POST['us'])) {
    $use_Recordset4 = (get_magic_quotes_gpc()) ? $_POST['us'] : addslashes($_POST['us']);
    }
    $pwd_Recordset4 = "-1";
    if (isset($_POST['pw'])) {
    $pwd_Recordset4 = (get_magic_quotes_gpc()) ? $_POST['pw'] : addslashes($_POST['pw']);
    }
    mysql_select_db($database_fanta, $fanta);
    $query_Recordset4 = sprintf("SELECT `cognome` FROM `giocatori` inner join accesso on accesso.team = giocatori.team WHERE (user= '%s') and (passw = '%s') ", $use_Recordset4,$pwd_Recordset4);
    $query_limit_Recordset4 = sprintf("%s LIMIT %d, %d", $query_Recordset4, $startRow_Recordset4, $maxRows_Recordset4);
    $Recordset4 = mysql_query($query_limit_Recordset4, $fanta) or die(mysql_error());
    $row_Recordset4 = mysql_fetch_assoc($Recordset4);

    if (isset($_GET['totalRows_Recordset4'])) {
    $totalRows_Recordset4 = $_GET['totalRows_Recordset4'];
    } else {
    $all_Recordset4 = mysql_query($query_Recordset4);
    $totalRows_Recordset4 = mysql_num_rows($all_Recordset4);
    }
    $totalPages_Recordset4 = ceil($totalRows_Recordset4/$maxRows_Recordset4)-1;

    $use_nomesq = "-1";
    if (isset($_POST['us'])) {
    $use_nomesq = (get_magic_quotes_gpc()) ? $_POST['us'] : addslashes($_POST['us']);
    }
    $pwd_nomesq = "-1";
    if (isset($_POST['pw'])) {
    $pwd_nomesq = (get_magic_quotes_gpc()) ? $_POST['pw'] : addslashes($_POST['pw']);
    }
    mysql_select_db($database_fanta, $fanta);
    $query_nomesq = sprintf("SELECT `user` FROM accesso WHERE (user= '%s') and (passw = '%s') ", $use_nomesq,$pwd_nomesq);
    $nomesq = mysql_query($query_nomesq, $fanta) or die(mysql_error());
    $row_nomesq = mysql_fetch_assoc($nomesq);
    $totalRows_nomesq = mysql_num_rows($nomesq);
    ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Documento senza titolo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <form action="<?php echo $editFormAction; ?>" method="post" name="formaz" id="formaz">
    <label>SQUADRA
    <select name="nomes" id="nomes">
    <?php
    do {
    ?>
    <option value="<?php echo $row_nomesq['user']?>"<?php if (!(strcmp($row_nomesq['user'], $row_nomesq['user']))) {echo "selected=\"selected\"";} ?>><?php echo $row_nomesq['user']?></option>
    <?php
    } while ($row_nomesq = mysql_fetch_assoc($nomesq));
    $rows = mysql_num_rows($nomesq);
    if($rows > 0) {
    mysql_data_seek($nomesq, 0);
    $row_nomesq = mysql_fetch_assoc($nomesq);
    }
    ?>
    </select>




    Giornata

    <select name="giornata" id="giornata">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    </select>




    <select name="1" id="1">
    <?php
    do {
    ?><option value="<?php echo $row_Recordset4['cognome']?>"<?php if (!(strcmp($row_Recordset4['cognome'], strtolower($row_Recordset4['cognome'])))) {echo "selected=\"selected\"";} ?>><?php echo $row_Recordset4['cognome']?></option><?php
    } while ($row_Recordset4 = mysql_fetch_assoc($Recordset4));
    $rows = mysql_num_rows($Recordset4);
    if($rows > 0) {
    mysql_data_seek($Recordset4, 0);
    $row_Recordset4 = mysql_fetch_assoc($Recordset4);
    }
    ?>
    </select>




    <select name="2" id="2">
    <?php
    do {
    ?>
    <option value="<?php echo $row_Recordset4['cognome']?>"<?php if (!(strcmp($row_Recordset4['cognome'], strtolower($row_Recordset4['cognome'])))) {echo "selected=\"selected\"";} ?>><?php echo $row_Recordset4['cognome']?></option>
    <?php
    } while ($row_Recordset4 = mysql_fetch_assoc($Recordset4));
    $rows = mysql_num_rows($Recordset4);
    if($rows > 0) {
    mysql_data_seek($Recordset4, 0);
    $row_Recordset4 = mysql_fetch_assoc($Recordset4);
    }
    ?>
    </select>




    <select name="3" id="3">
    <?php
    do {
    ?>
    <option value="<?php echo $row_Recordset4['cognome']?>"<?php if (!(strcmp($row_Recordset4['cognome'], strtolower($row_Recordset4['cognome'])))) {echo "selected=\"selected\"";} ?>><?php echo $row_Recordset4['cognome']?></option>
    <?php
    } while ($row_Recordset4 = mysql_fetch_assoc($Recordset4));
    $rows = mysql_num_rows($Recordset4);
    if($rows > 0) {
    mysql_data_seek($Recordset4, 0);
    $row_Recordset4 = mysql_fetch_assoc($Recordset4);
    }
    ?>
    </select>




    <select name="4" id="4">
    <?php
    do {
    ?>
    <option value="<?php echo $row_Recordset4['cognome']?>"<?php if (!(strcmp($row_Recordset4['cognome'], strtolower($row_Recordset4['cognome'])))) {echo "selected=\"selected\"";} ?>><?php echo $row_Recordset4['cognome']?></option>
    <?php
    } while ($row_Recordset4 = mysql_fetch_assoc($Recordset4));
    $rows = mysql_num_rows($Recordset4);
    if($rows > 0) {
    mysql_data_seek($Recordset4, 0);
    $row_Recordset4 = mysql_fetch_assoc($Recordset4);
    }
    ?>
    </select>




    <select name="5" id="5">
    <?php
    do {
    ?>
    <option value="<?php echo $row_Recordset4['cognome']?>"<?php if (!(strcmp($row_Recordset4['cognome'], strtolower($row_Recordset4['cognome'])))) {echo "selected=\"selected\"";} ?>><?php echo $row_Recordset4['cognome']?></option>
    <?php
    } while ($row_Recordset4 = mysql_fetch_assoc($Recordset4));
    $rows = mysql_num_rows($Recordset4);
    if($rows > 0) {
    mysql_data_seek($Recordset4, 0);
    $row_Recordset4 = mysql_fetch_assoc($Recordset4);
    }
    ?>
    </select>






    <input type="submit" name="Submit" value="ANTEPRIMA" id="Submit">
    <input type="reset" name="Submit2" value="RESET" id="Submit2">
    <input type="hidden" name="MM_insert" value="formaz">


    </label>
    </form>
    </body>
    </html>
    <?php
    mysql_free_result($Recordset4);

    mysql_free_result($nomesq);
    ?>

  2. #2
    Utente di HTML.it
    Registrato dal
    Sep 2006
    Messaggi
    81
    credo che l'errore me lo dia qui


    $insertGoTo = "preview.php";
    if (isset ($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
    }
    header(sprintf("Location: %s", $insertGoTo));

  3. #3
    Utente di HTML.it L'avatar di M4rko
    Registrato dal
    Dec 2000
    Messaggi
    619
    Nelle prime righe:

    codice:
    <?php require_once('Connections/fanta.php'); ?>
    <?php require_once('Connections/fanta.php'); ?>
    <?php
    // bla bla bla
    Innanzi tutto non ha senso fare due require_once dello stesso file

    In secondo luogo, chiudendo il tag PHP ed andando a capo, produci un output (il carattere "a capo", appunto) che ti causa quell'errore

    Sostituisci quelle righe con

    codice:
    <?php
    require_once('Connections/fanta.php');
    // bla bla bla (senza chiudere e riaprire il tag php
    Tutti hanno bisogno di credere in qualcosa.
    Io credo che mi farò un'altra birra.


  4. #4
    Utente di HTML.it
    Registrato dal
    Sep 2006
    Messaggi
    81
    grazie dell'aiuto ... se avro' ancora bisogno so dove cercarti

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.