表单发布href将更多字符串发送到另一个页面

问题描述 投票:0回答:1

我有一个Bootstrap CRUD页面。它也只有大约1200行,运行非常缓慢。

    <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title> MAGAZZINO COMPONENTI</title>
</head>
<body style="margin:0;">
    <div id="header" align=center>
        <font color="black">
        <h2>MAGAZZINO COMPONENTI</h2>
    </div>
    <div class="container-fluid">
        <div class="row">
        <a href="#aggiungi" data-toggle="modal">
                <button type='button' class='btn btn-success btn-sm'><span class='glyphicon glyphicon-plus' aria-hidden='true'></span> Codice</button>
            </a>
        </div>
        <br>
        <table id="example" class="display nowrap" cellspacing="0" width="100%" data-side-pagination="server">
            <thead>
                <tr>
                    <th>Id</th>
                    <th>Codice</th>
                    <th>Codice fornitore</th>
                    <th>Ubicazione</th>
                    <th>Descrizione</th>
                    <th>Package</th>
                    <th>Quantità</th>
                    <th> </th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <th>Id</th>
                    <th>Codice</th>
                    <th>Codice fornitore</th>
                    <th>Ubicazione</th>
                    <th>Descrizione</th>
                    <th>Package</th>
                    <th>Quantità</th>
                    <th> </th>
                </tr>
            </tfoot>
            <tbody>
                <?php 
                    $sql = "SELECT id, codice, cod_forn, ubicazione, descrizione, package, quantita 
                            FROM maglab";
                    $result = $conn->query($sql);
                    if ($result->num_rows > 0) {
                        // output data of each row
                        while($row = $result->fetch_assoc()) {
                            $id = $row['id'];
                            $codice = $row['codice'];
                            $cod_forn = $row['cod_forn'];
                            $ubicazione = $row['ubicazione'];
                            $descrizione = $row['descrizione'];
                            $package = $row['package'];
                            $quantita = $row['quantita'];

                            if($quantita == 0){
                                $alert = "<div class='alert alert-danger'>
                                <strong>$quantita</strong> No Stock
                                </div>";
                            }else {
                                $alert = $quantita;
                            }                    

                            echo "<tr>";
                                echo "<td>" .$id ."</td>";
                                echo "<td>" .$codice ."</td>";
                                echo "<td>" .wordwrap($cod_forn, 35, "<br />", true) ."</td>";
                                echo "<td>" .$ubicazione ."</td>";
                                echo "<td>" .wordwrap($descrizione, 35, "<br />", true) ."</td>";
                                echo "<td>" .$package ."</td>";
                                echo "<td>" .$alert ."</td>";
                ?>

                            <td>                                
                                <a href="#scarica<?php echo $id;?>" data-toggle="modal">
                                    <button type='button' class='btn btn-default btn-sm'><span class='glyphicon glyphicon-minus' aria-hidden='true' title="Scarica"></span></button>
                                </a>
                                <a href="#carica<?php echo $id;?>" data-toggle="modal">
                                    <button type='button' class='btn btn-success btn-sm'><span class='glyphicon glyphicon-plus' aria-hidden='true' title="Carica"></span></button>
                                </a>
                                <a href="#modifica<?php echo $id;?>" data-toggle="modal">
                                    <button type='button' class='btn btn-warning btn-sm'><span class='glyphicon glyphicon-edit' aria-hidden='true' title="Modifica"></span></button>
                                </a>
                                <a href="#cancella<?php echo $id;?>" data-toggle="modal">
                                    <button type='button' class='btn btn-danger btn-sm'><span class='glyphicon glyphicon-trash' aria-hidden='true' title="Cancella"></span></button>
                                </a>
                            </td>

                <?php echo "</tr>"; ?>

                <!--Unload q.ty Modal -->
                <div id="scarica<?php echo $id; ?>" class="modal fade" role="dialog">
                    <div class="modal-dialog modal-lg">
                        <form method="post" class="form-horizontal" role="form">
                            <!-- Modal content-->
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                                    <h4 class="modal-title">Scarica</h4>
                                </div>
                                <div class="modal-body">
                                    <div class="form-group">
                                        <label class="control-label col-sm-2" for="codice">Codice:</label>
                                        <div class="col-sm-4">
                                            <input type="hidden" name="minus_stocks_id" value="<?php echo $id; ?>">
                                            <input type="hidden" name="descrizione" value="<?php echo $descrizione; ?>">
                                            <input type="text" class="form-control" id="codice" name="codice" required readonly value="<?php echo $codice; ?>"> </div>
                                        <label class="control-label col-sm-2" for="ubicazione">Ubicazione:</label>
                                        <div class="col-sm-2">
                                            <input type="text" class="form-control" id="ubicazione" name="ubicazione" required readonly value="<?php echo $ubicazione; ?>"> </div>
                                        <br>
                                        <br>
                                        <br>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-2" for="quantita">Quantità:</label>
                                        <div class="col-sm-4">
                                            <input type="number" class="form-control" id="quantita" name="quantita" autofocus required min="1"> </div>
                                        <label class="control-label col-sm-2" for="causale">Causale:</label>
                                        <div class="col-sm-2">
                                            <select required id="causale" name="causale">
                                                <option value="">Seleziona</option>
                                                <option value="Scarico">Scarico</option>
                                                <option value="Scarto">Scarto</option>
                                                <option value="Spedito">Spedito</option>
                                            <!--input type="submit" value="Submit"-->
                                            </select>
                                        </div>
                                        <br>
                                        <br>
                                        <br>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <button type="submit" class="btn btn-primary" name="minus_company"><span class="glyphicon glyphicon-minus"></span> Scarica</button>
                                    <button type="button" class="btn btn-warning" data-dismiss="modal"><span class="glyphicon glyphicon-remove-circle"></span> Annulla</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>  

                <!--Edit Item Modal -->
                <div id="modifica<?php echo $id; ?>" class="modal fade" role="dialog">
                    <form method="post" class="form-horizontal" role="form">
                        <div class="modal-dialog modal-lg">
                            <!-- Modal content-->
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                                    <h4 class="modal-title">Modifica articolo</h4>
                                </div>
                                <div class="modal-body">
                                    <input type="hidden" name="edit_id" value="<?php echo $id; ?>">
                                    <div class="form-group">
                                        <label class="control-label col-sm-2" for="codice">Codice:</label>
                                        <div class="col-sm-4">
                                            <input type="text" class="form-control" id="codice" name="codice" value="<?php echo $codice; ?>" required autofocus> </div>
                                            <label class="control-label col-sm-2" for="codice">Codice fornitore:</label>
                                        <div class="col-sm-4">
                                            <textarea class="form-control" rows="3" id="cod_forn" name="cod_forn" style="width: 100%;"> <?php echo $cod_forn; ?> </textarea>
                                        </div>
                                    </div>
                                    <br>
                                    <br>
                                    <br>
                                    <br>
                                    <div class="form-group">
                                        <label class="control-label col-sm-2" for="ubicazione">Ubicazione:</label>
                                        <div class="col-sm-4">
                                            <input type="text" class="form-control" id="ubicazione" name="ubicazione" value="<?php echo $ubicazione; ?>"> </div>
                                        <label class="control-label col-sm-2" for="descrizione">Descrizione:</label>
                                        <div class="col-sm-4">
                                            <textarea class="form-control" rows="3" id="descrizione" name="descrizione" style="width: 100%;"> <?php echo $descrizione; ?> </textarea>
                                        </div>
                                    <br>
                                    <br>
                                    <br>
                                    <br>
                                    <br>
                                    <div class="form-group">
                                        <label class="control-label col-sm-2" for="package">Package:</label>
                                        <div class="col-sm-4">
                                            <input type="text" class="form-control" id="package" name="package" value="<?php echo $package; ?>"> </div>
                                        <label class="control-label col-sm-2" for="quantita">Quantita:</label>
                                        <div class="col-sm-4">
                                            <input type="text" class="form-control" id="quantita" name="quantita" value="<?php echo $quantita; ?>" required> </div>
                                    </div>
                                    <br>
                                    <br>
                                    <div class="form-group">
                                        <label class="control-label col-sm-2" for="causale">Causale:</label>
                                        <div class="col-sm-2">
                                            <select required id="causale" name="causale">
                                                <option value="">Seleziona</option>
                                                <option value="Inventario">Inventario</option>
                                                <option value="Modifica">Modifica</option>
                                            </select>
                                        </div>
                                    </div>
                                    <br>
                                    <br>
                                    <br>
                                    <br>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <button type="submit" class="btn btn-primary" name="update_item"><span class="glyphicon glyphicon-edit"></span> Modifica</button>
                                    <button type="button" class="btn btn-warning" data-dismiss="modal"><span class="glyphicon glyphicon-remove-circle"></span> Annulla</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>

                <!--Delete Modal -->
                <div id="cancella<?php echo $id; ?>" class="modal fade" role="dialog">
                    <div class="modal-dialog">
                        <form method="post">
                            <!-- Modal content-->
                            <div class="modal-content">
                                <div class="form-group">
                                        <input type="hidden" name="delete_id" value="<?php echo $id; ?>">
                                        <input type="hidden" name="descrizione" value="<?php echo $descrizione; ?>">
                                        <!--label class="control-label col-sm-2" for="codice">Codice:</label-->
                                        <div class="col-sm-4">                                                
                                            <input type="hidden" class="form-control" id="codice" name="codice" required readonly value="<?php echo $codice; ?>"> </div>
                                        <!--label class="control-label col-sm-2" for="codice">Quantità:</label-->
                                        <div class="col-sm-2">
                                            <input type="hidden" class="form-control" id="quantita" name="quantita" value="<?php echo $quantita; ?>" required> </div>                           
                                </div>
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                                    <h4 class="modal-title">Cancella</h4>
                                </div>
                                <div class="modal-body">
                                    <input type="hidden" name="delete_id" value="<?php echo $id; ?>">
                                    <div class="alert alert-danger">Sicuro di voler cancellare <strong>
                                            <?php echo $codice; ?> ?</strong> </div>
                                    <div class="modal-footer">
                                        <button type="submit" name="delete" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span> SI</button>
                                        <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove-circle"></span> NO</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>  

                <?php
                        }

                    //Update Items
                    if(isset($_POST['update_item'])){                               
                        $edit_id = $_POST['edit_id'];
                        $codice = $_POST['codice'];
                        $cod_forn = $_POST['cod_forn'];
                        $ubicazione = $_POST['ubicazione'];
                        $descrizione = $_POST['descrizione'];
                        $package = $_POST['package'];
                        $quantita = $_POST['quantita'];
                        $causale = $_POST['causale'];
                        $sql = "UPDATE maglab SET 
                            codice='$codice',
                            cod_forn='$cod_forn',
                            ubicazione='$ubicazione',
                            descrizione='$descrizione',
                            package='$package',
                            quantita='$quantita'
                            WHERE id='$edit_id' ";
                        if ($conn->query($sql) === TRUE) {
                            // Registra movimento
                            $sql = "INSERT INTO movimenti_codici (utente, data, codice, descrizione, quantita, movimento) 
                                    VALUES ('$session_username', CURDATE(), '$codice', '$descrizione', '$quantita', '$causale')";
                            if ($conn->query($sql) === TRUE) {
                                echo '<script>window.location.href="magazzino.php"</script>';
                            } else {
                                //echo "Errore: " . $sql . "<br>" . $conn->error;
                                echo '<script language="javascript">alert("Errore: ' . $sql . "<br>" . $conn->error .'")</script>';
                            }                               
                            echo '<script>window.location.href="magazzino.php"</script>';
                        } else {
                            //echo "Errore aggiornamento record: " . $conn->error;
                            echo '<script language="javascript">alert("Errore aggiornamento record: '. $conn->error .'")</script>';
                        } 
                    }

                    //Delete Item
                    if(isset($_POST['delete'])){
                        $delete_id = $_POST['delete_id'];
                        $codice = $_POST['codice'];
                        $quantita = $_POST['quantita'];
                        $descrizione = $_POST['descrizione'];
                        $sql = "DELETE FROM maglab WHERE id='$delete_id' ";
                        if ($conn->query($sql) === TRUE) {
                            // Registra movimento
                            $sql = "INSERT INTO movimenti_codici (utente, data, codice, descrizione, quantita, movimento) 
                                    VALUES ('$session_username', CURDATE(), '$codice', '$descrizione', '$quantita', 'Cancellato')";
                            if ($conn->query($sql) === TRUE) {
                                echo '<script>window.location.href="magazzino.php"</script>';
                            } else {
                                //echo "Errore: " . $sql . "<br>" . $conn->error;
                                echo '<script language="javascript">alert("Errore: ' . $sql . "<br>" . $conn->error .'")</script>';
                            }
                            echo '<script>window.location.href="magazzino.php"</script>';
                        } else {
                            //echo "Errore cancellazione record: " . $conn->error;
                            echo '<script language="javascript">alert("Errore cancellazione record: '. $conn->error .'")</script>'; 
                        }
                    }
                    }



                    //Unload qty
                    if(isset($_POST['minus_company'])){
                        $minus_stocks_id = clean($_POST['minus_stocks_id']);
                        $codice = $_POST['codice'];
                        $descrizione = $_POST['descrizione'];
                        $quantita = clean($_POST['quantita']);
                        $causale = $_POST['causale'];
                        /* PER I GEIZEER RICORDA DI SCARICARE GHIACCIOLI */ 
                        if(substr($codice, 0, 11) == 'GZ01MC0001A'){
                            echo '<script language="javascript">alert("Scaricare ghiaccioli aggiuntivi")</script>';
                        }
                        $add_inv = "UPDATE maglab SET quantita=(quantita - '$quantita') WHERE id='$minus_stocks_id' ";
                        if ($conn->query($add_inv) === TRUE) {
                            // Registra movimento
                            $sql = "INSERT INTO movimenti_codici (utente, data, codice, descrizione, quantita, movimento) 
                                    VALUES ('$session_username', CURDATE(), '$codice', '$descrizione', '$quantita', '$causale')";
                            if ($conn->query($sql) === TRUE) {
                                echo '<script>window.location.href="magazzino.php"</script>';
                            } else {
                                //echo "Errore: " . $sql . "<br>" . $conn->error;
                                echo '<script language="javascript">alert("Errore: ' . $sql . "<br>" . $conn->error .'")</script>';
                            }                               
                            echo '<script>window.location.href="magazzino.php"</script>';
                        } else {
                            //echo "Errore aggiornamento record: " . $conn->error;
                            echo '<script language="javascript">alert("Errore aggiornamento record: '. $conn->error .'")</script>';
                        }                           
                    }
                ?>
            </tbody>
        </table>
    </div>

                </form>
            </div>
        </div>
    </div>
</body>
</html>

对我来说,问题是,每行它都用相关代码加载所有4个CRUD按钮。我想以这种方式修改代码

    <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title> MAGAZZINO COMPONENTI</title>
</head>
<body style="margin:0;">
    <div id="header" align=center>
        <font color="black">
        <h2>MAGAZZINO COMPONENTI</h2>
    </div>
    <div class="container-fluid">
        <div class="row">
        <a href="#aggiungi" data-toggle="modal">
                <button type='button' class='btn btn-success btn-sm'><span class='glyphicon glyphicon-plus' aria-hidden='true'></span> Codice</button>
            </a>
        </div>
        <br>
        <table id="example" class="display nowrap" cellspacing="0" width="100%" data-side-pagination="server">
            <thead>
                <tr>
                    <th>Id</th>
                    <th>Codice</th>
                    <th>Codice fornitore</th>
                    <th>Ubicazione</th>
                    <th>Descrizione</th>
                    <th>Package</th>
                    <th>Quantità</th>
                    <th> </th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <th>Id</th>
                    <th>Codice</th>
                    <th>Codice fornitore</th>
                    <th>Ubicazione</th>
                    <th>Descrizione</th>
                    <th>Package</th>
                    <th>Quantità</th>
                    <th> </th>
                </tr>
            </tfoot>
            <tbody>
                <?php 
                    $sql = "SELECT id, codice, cod_forn, ubicazione, descrizione, package, quantita 
                            FROM maglab";
                    $result = $conn->query($sql);
                    if ($result->num_rows > 0) {
                        // output data of each row
                        while($row = $result->fetch_assoc()) {
                            $id = $row['id'];
                            $codice = $row['codice'];
                            $cod_forn = $row['cod_forn'];
                            $ubicazione = $row['ubicazione'];
                            $descrizione = $row['descrizione'];
                            $package = $row['package'];
                            $quantita = $row['quantita'];

                            if($quantita == 0){
                                $alert = "<div class='alert alert-danger'>
                                <strong>$quantita</strong> No Stock
                                </div>";
                            }else {
                                $alert = $quantita;
                            }                    

                            echo "<tr>";
                                echo "<td>" .$id ."</td>";
                                echo "<td>" .$codice ."</td>";
                                echo "<td>" .wordwrap($cod_forn, 35, "<br />", true) ."</td>";
                                echo "<td>" .$ubicazione ."</td>";
                                echo "<td>" .wordwrap($descrizione, 35, "<br />", true) ."</td>";
                                echo "<td>" .$package ."</td>";
                                echo "<td>" .$alert ."</td>";
                ?>

                            <td>                                
                                <form enctype='multipart/form-data' method='post'>                                  
                                    <a href="crudMagazzino.php?id=<?php echo $id; .echo $codice; ?>" data-toggle="modal">
                                        <button type='button' class='btn btn-success btn-sm'><span class='glyphicon glyphicon-minus' aria-hidden='true' title="Scarica"></span></button>
                                    </a>
                                    <a href="#carica<?php echo $id;?>" data-toggle="modal">
                                        <button type='button' class='btn btn-success btn-sm'><span class='glyphicon glyphicon-plus' aria-hidden='true' title="Carica"></span></button>
                                    </a>
                                    <a href="#modifica<?php echo $id;?>" data-toggle="modal">
                                        <button type='button' class='btn btn-warning btn-sm'><span class='glyphicon glyphicon-edit' aria-hidden='true' title="Modifica"></span></button>
                                    </a>
                                    <a href="#cancella<?php echo $id;?>" data-toggle="modal">
                                        <button type='button' class='btn btn-danger btn-sm'><span class='glyphicon glyphicon-trash' aria-hidden='true' title="Cancella"></span></button>
                                    </a>
                                </form>
                            </td>

                <?php echo "</tr>"; 

                        }                   
                    }

                    //Add Item        
                    if(isset($_POST['add_item'])){
                        $codice = $_POST['codice'];
                        $cod_forn = $_POST['cod_forn'];
                        $ubicazione = $_POST['ubicazione'];
                        $descrizione = $_POST['descrizione'];
                        $package = $_POST['package'];
                        $quantita = $_POST['quantita'];
                        $sql = "INSERT INTO maglab (codice,cod_forn, ubicazione, descrizione, package, quantita)
                                            VALUES ('$codice', '$cod_forn', '$ubicazione', '$descrizione', '$package', '$quantita')";
                        if ($conn->query($sql) === TRUE) {
                            // Registra movimento
                            $sql = "INSERT INTO movimenti_codici (utente, data, codice, descrizione, quantita, movimento) 
                                    VALUES ('$session_username', CURDATE(), '$codice', '$descrizione', '$quantita', 'Creato')";
                            if ($conn->query($sql) === TRUE) {
                                echo '<script>window.location.href="magazzino.php"</script>';
                            } else {
                                //echo "Errore: " . $sql . "<br>" . $conn->error;
                                echo '<script language="javascript">alert("Errore: ' . $sql . "<br>" . $conn->error .'")</script>';
                            }                               
                            echo '<script>window.location.href="magazzino.php"</script>';
                        } else {
                            //echo "Errore: " . $sql . "<br>" . $conn->error;
                            echo '<script language="javascript">alert("Errore: ' . $sql . "<br>" . $conn->error .'")</script>';
                        }                           
                    }                   
                ?>
            </tbody>
        </table>
    </div>

    <!--Add Item Modal -->
    <div id="aggiungi" class="modal fade" role="dialog">
        <div class="modal-dialog modal-lg">
            <!-- Modal content-->
            <div class="modal-content">
                <form method="post" class="form-horizontal" role="form">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                        <h4 class="modal-title">Aggiungi codice</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <label class="control-label col-sm-2" for="id">Id:</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" id="codice" name="codice" value="<?php echo $id+1; ?>" readonly> 
                            </div>                      
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-2" for="codice">Codice:</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" id="codice" name="codice" autofocus required> 
                            </div>
                            <label class="control-label col-sm-2" for="cod_forn">Codice fornitore:</label>
                            <div class="col-sm-4">
                                <textarea class="form-control" rows="3" id="cod_forn" name="cod_forn"></textarea>
                            </div>                          
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-2" for="ubicazione">Ubicazione:</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" id="ubicazione" name="ubicazione"> 
                            </div>
                            <label class="control-label col-sm-2" for="descrizione">Descrizione:</label>
                            <div class="col-sm-4">
                                <textarea class="form-control" rows="3" id="descrizione" name="descrizione"></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-2" for="package">Package:</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" id="package" name="package"> 
                            </div>
                            <label class="control-label col-sm-2" for="quantita">Quantità:</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" id="quantita" name="quantita" required> 
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="submit" class="btn btn-primary" name="add_item"><span class="glyphicon glyphicon-plus"></span> Aggiungi</button>
                        <button type="button" class="btn btn-warning" data-dismiss="modal"><span class="glyphicon glyphicon-remove-circle"></span> Annulla</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</body>
</html>

当我按下CRUD按钮时,程序将转到另一个(或更多)页面crudMagazzino.php以执行所需的操作

    <?php include 'menu.html'; 
    $id = $_GET['id'];
    $codice = $_GET['codice'];
    $cod_forn = $_GET['cod_forn'];
    $ubicazione = $_GET['ubicazione'];
    $descrizione = $_GET['descrizione'];
    $package = $_GET['package'];
    $quantita = $_GET['quantita'];
?>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title> CRUD MAGAZZINO COMPONENTI</title>
</head>
<body>                  
    <!--Unload q.ty Modal -->
    <div id="scarica<?php echo $id; ?>" class="modal fade" role="dialog">
        <div class="modal-dialog modal-lg">
            <form method="post" class="form-horizontal" role="form">
                <!-- Modal content-->
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                        <h4 class="modal-title">Scarica</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <label class="control-label col-sm-2" for="codice">Codice:</label>
                            <div class="col-sm-4">
                                <input type="hidden" name="minus_stocks_id" value="<?php echo $id; ?>">
                                <input type="hidden" name="descrizione" value="<?php echo $descrizione; ?>">
                                <input type="text" class="form-control" id="codice" name="codice" required readonly value="<?php echo $codice; ?>"> </div>
                            <label class="control-label col-sm-2" for="ubicazione">Ubicazione:</label>
                            <div class="col-sm-2">
                                <input type="text" class="form-control" id="ubicazione" name="ubicazione" required readonly value="<?php echo $ubicazione; ?>"> </div>
                            <br>
                            <br>
                            <br>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-2" for="quantita">Quantità:</label>
                            <div class="col-sm-4">
                                <input type="number" class="form-control" id="quantita" name="quantita" autofocus required min="1"> </div>
                            <label class="control-label col-sm-2" for="causale">Causale:</label>
                            <div class="col-sm-2">
                                <select required id="causale" name="causale">
                                    <option value="">Seleziona</option>
                                    <option value="Scarico">Scarico</option>
                                    <option value="Scarto">Scarto</option>
                                    <option value="Spedito">Spedito</option>
                                <!--input type="submit" value="Submit"-->
                                </select>
                            </div>
                            <br>
                            <br>
                            <br>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="submit" class="btn btn-primary" name="minus_company"><span class="glyphicon glyphicon-minus"></span> Scarica</button>
                        <button type="button" class="btn btn-warning" data-dismiss="modal"><span class="glyphicon glyphicon-remove-circle"></span> Annulla</button>
                    </div>
                </div>
            </form>
        </div>
    </div>  

    <?php 

    //Unload qty
    if(isset($_POST['minus_company'])){
        $minus_stocks_id = clean($_POST['minus_stocks_id']);
        $codice = $_POST['codice'];
        $descrizione = $_POST['descrizione'];
        $quantita = clean($_POST['quantita']);
        $causale = $_POST['causale'];
        /* PER I GEIZEER RICORDA DI SCARICARE GHIACCIOLI */ 
        if(substr($codice, 0, 11) == 'GZ01MC0001A'){
            echo '<script language="javascript">alert("Scaricare ghiaccioli aggiuntivi")</script>';
        }
        $add_inv = "UPDATE maglab SET quantita=(quantita - '$quantita') WHERE id='$minus_stocks_id' ";
        if ($conn->query($add_inv) === TRUE) {
            // Registra movimento
            $sql = "INSERT INTO movimenti_codici (utente, data, codice, descrizione, quantita, movimento) 
                    VALUES ('$session_username', CURDATE(), '$codice', '$descrizione', '$quantita', '$causale')";
            if ($conn->query($sql) === TRUE) {
                echo '<script>window.location.href="magazzino.php"</script>';
            } else {
                //echo "Errore: " . $sql . "<br>" . $conn->error;
                echo '<script language="javascript">alert("Errore: ' . $sql . "<br>" . $conn->error .'")</script>';
            }                               
            echo '<script>window.location.href="magazzino.php"</script>';
        } else {
            //echo "Errore aggiornamento record: " . $conn->error;
            echo '<script language="javascript">alert("Errore aggiornamento record: '. $conn->error .'")</script>';
        }                           
    }

    ?>
</body>
</html>

我如何在这部分代码中传递多个字符串?我的意思是将id,codice,cod_forn等传递给crudMagazzino.php

<a href="crudMagazzino.php?id=<?php echo $id .' '.$codice; ?>" data-toggle="modal">
    <button type='button' class='btn btn-success btn-sm'><span class='glyphicon glyphicon-minus' aria-hidden='true' title="Scarica"></span></button>
</a>
php html post href
1个回答
0
投票

解决方案是:

<a href="crudMagazzino.php?id=<?php echo $id; ?>&amp;
                                          codice=<?php echo $codice; ?>&amp;
                                          cod_forn=<?php echo $cod_forn; ?>&amp;
                                          ubicazione=<?php echo $ubicazione; ?>&amp;
                                          descrizione=<?php echo $descrizione; ?>&amp;
                                          package=<?php echo $package; ?>&amp;
                                          quantita=<?php echo $quantita; ?>&amp;
                             " data-toggle="modal">                                 
    <button type='button' class='btn btn-success btn-sm'><span class='glyphicon glyphicon-minus' aria-hidden='true' title="Scarica"></span></button>
</a>
© www.soinside.com 2019 - 2024. All rights reserved.