Pagina 2 di 2 primaprima 1 2
Visualizzazione dei risultati da 11 a 13 su 13
  1. #11
    questo è il codice php che ho trovato. funziona ma c'e il modo di mettere il mio al posto di quello che c è?

    function elh_insert_into_db() {

    global $wpdb;
    // creates my_table in database if not exists
    $table = $wpdb->prefix . "my_table";
    $charset_collate = $wpdb->get_charset_collate();
    $sql = "CREATE TABLE IF NOT EXISTS $table (
    `id` mediumint(9) NOT NULL AUTO_INCREMENT,
    `name` text NOT NULL,
    UNIQUE (`id`)
    ) $charset_collate;";
    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    dbDelta( $sql );
    // starts output buffering
    ob_start();
    ?>

    <form action="#v_form" method="post" id="v_form">
    <label for="visitor_name"><h3>Nome</h3></label>
    <input type="text" name="visitor_name" id="visitor_name" />
    <input type="submit" name="submit_form" value="submit" />
    </form>
    <?php
    $html = ob_get_clean();
    // does the inserting, in case the form is filled and submitted
    if ( isset( $_POST["submit_form"] ) && $_POST["visitor_name"] != "" ) {
    $table = $wpdb->prefix."my_table";
    $name = strip_tags($_POST["visitor_name"], "");
    $wpdb->insert(
    $table,
    array(
    'name' => $name
    )
    );




    $html = "<p>Your name <strong>$name</strong> was successfully recorded. Thanks!!</p>";
    }
    // if the form is submitted but the name is empty
    if ( isset( $_POST["submit_form"] ) && $_POST["visitor_name"] == "" )
    $html .= "<p>You need to fill the required fields.</p>";
    // outputs everything
    return $html;

    }
    // adds a shortcode you can use: [insert-into-db]
    add_shortcode('elh-db-insert', 'elh_insert_into_db');

  2. #12
    a ok ci provo, grazie mille

  3. #13
    Moderatore di Javascript L'avatar di ciro78
    Registrato dal
    Sep 2000
    residenza
    Napoli
    Messaggi
    8,505
    gabriele fossi in te leggerei il regolamento con attenzione.

    per adesso chiudo. 18 messaggi e violi le regole base del forum.
    Ciro Marotta - Programmatore JAVA - PHP
    Preferisco un fallimento alle mie condizioni che un successo alle condizioni altrui.


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.