Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente bannato
    Registrato dal
    May 2006
    Messaggi
    25

    $_POST / prendere le variabili

    salve,
    ho 1 problemino con 1 form dove ci sono tantissime variabili chiamate
    Codice PHP:
    $dom121='testotestotest';
    $dom134='testotestotest';
    $dom155='testotestotest';
    $dom192='testotestotest';
    //etc... 
    visto che sono tante, come faccio a:
    1) prendere solo quelle che abbiano una stringa non nulla
    2) identificarle col nome (insomma la $dom201 sarà diversa dalla $dom591 e così via..) per inserirle nel db?



    sto provando con le variabili di variabili ma zero assoluto!


    ah dimenticavo!
    il server non prende variabili con numeri!!
    Codice PHP:
    $1
    $dom129 

  2. #2

    Non ho ben capito .....

    Ciao.
    quello che stai cercando tiro
    ad indovinare e ti passo questo
    snipet con cui puoi fare un insert
    con tutti i campi che vuoi:
    <?php
    class Insert
    {
    var $_SQLStatement = "";
    function Insert()
    {
    $sql_columns_use = array();
    $sql_value_use = array();
    array_pop($_POST);
    foreach($_POST as $key => $value)
    {
    $value = trim($value);
    if (is_numeric($value))
    {
    $sql_value_use[] = $value;
    }
    else
    {
    $sql_value_use[] = (get_magic_quotes_gpc()) ? "'".$value."'" : "'".addslashes($value)."'";
    }
    $sql_columns_use[] = $key;
    }
    $this->_SQLStatement = "INSERT INTO ".$tbl." (".implode(",",$sql_columns_use).") VALUES (".implode(",",$sql_value_use).")";
    }

    }//
    ?>
    <?php
    $obj = new Insert();
    if(isset($_POST['name']))
    {
    var_dump($obj->SQLStatement);
    }
    ?>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="myForm">


    Name: <input name="name" type="text"></p>


    Age: <input name="email" type="text"></p>


    Phone Number: <input name="tel" type="text"></p>


    <input name="action" type="submit" value="AddToDB"></p>
    </form>
    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  3. #3
    Utente bannato
    Registrato dal
    May 2006
    Messaggi
    25
    non ci ho capito molto....

    grazie lo stesso, per ora il problema rimane insoluto!

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.