Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 12
  1. #1
    Utente di HTML.it
    Registrato dal
    Dec 2008
    Messaggi
    110

    Passaggio variabili POST jquery

    Ciao a tutti
    ho creato un form che tramite javascript ( jquery ) prende le variabili di un form e le passa tramite POST

    $.ajax({
    data: "post",
    url: "includes/ValidUserAdd.php",
    data: dataString,
    success: function() {
    $('#widget2').append("<div id='message'></div>");
    $('#message').html("<h2>Contact Form Submitted!</h2>").append("

    We will be in touch soon.</p>")
    .hide()
    .fadeIn(1500, function() {
    $('#message').append("[img]images/check.png[/img]");
    });
    }
    });

    ad una pagina ValidUserAdd.php che valida i campi e li passa ad un'altra pagina php dove viene eseguita la query.


    Codice PHP:

    require "classes/Mysql.php";

    $mysql= New Mysql();


    if ((isset(
    $_POST['nome'])) && (strlen(trim($_POST['nome'])) > 0)) { $nome stripslashes(strip_tags($_POST['nome']));} 
    if ((isset(
    $_POST['cognome'])) && (strlen(trim($_POST['cognome'])) > 0)) { $cognome stripslashes(strip_tags($_POST['cognome'])); } 
    if ((isset(
    $_POST['citta'])) && (strlen(trim($_POST['citta'])) > 0)) { $citta stripslashes(strip_tags($_POST['citta'])); } 
    if ((isset(
    $_POST['email'])) && (strlen(trim($_POST['email'])) > 0)) { $email stripslashes(strip_tags($_POST['email'])); } 
    if ((isset(
    $_POST['username'])) && (strlen(trim($_POST['username'])) > 0)) { $username stripslashes(strip_tags($_POST['username'])); }
    if ((isset(
    $_POST['password'])) && (strlen(trim($_POST['password'])) > 0)) { $password stripslashes(strip_tags($_POST['password'])); }

    $array_form = array("nome"=>'$nome',"cognome"=>"$cognome","citta"=>"$citta","email"=>"$email","username"=>"$username","password"=>"$password");

    $mysql->useradd($array_form); 
    Il problema sta che non mi mette niente nel db.

    :-(

  2. #2
    Utente di HTML.it
    Registrato dal
    Dec 2008
    Messaggi
    110
    up

  3. #3
    Cosa c'è in dataString


    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  4. #4
    Utente di HTML.it
    Registrato dal
    Dec 2008
    Messaggi
    110
    var dataString = 'nome='+ nome + '&cognome=' + cognome +'&username=' + username + '&email=' + password + '&password=' + email + '&citta=' + citta;

    i valori presi da un form.

  5. #5
    Guarda cosa spedisce con Firebug.

    Lo script php con una normale form
    funziona ?

    Solitamente in questi casi si fa un check
    per esempio dall'insert ti fai restituire
    con ad esempio mysql_insert_id
    (in caso di errore restituirai zero o simili)
    così hai maggiore controllo sullo script.


    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  6. #6
    Utente di HTML.it
    Registrato dal
    Dec 2008
    Messaggi
    110
    Come uso firebug per fare il debug? Non l'ho mai usato..scusa la domanda da newbie..

  7. #7
    Codice PHP:
    $array_form = array("nome"=>'$nome',"cognome"=>"$cognome","citta"=>"$citta","email"=>"$email","username"=>"$username","password"=>"$password"); 
    togli gli apici alle variabili che c'entrano ?

    non vedo il comportamento dello script in caso di errori
    dell'user ...............................

    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  8. #8
    Utente di HTML.it
    Registrato dal
    Dec 2008
    Messaggi
    110
    La console di firebug mi da questo errore..

    Fatal error: require_once() [function.require]: Failed opening
    required '/classes/Mysql.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/member
    /includes/ValidUserAdd.php
    on line 2<br /

    ma non capisco xkè i file si trovano in quelle path.

  9. #9
    Utente di HTML.it
    Registrato dal
    Dec 2008
    Messaggi
    110
    Originariamente inviato da alien1985
    var dataString = 'nome='+ nome + '&cognome=' + cognome +'&username=' + username + '&email=' + password + '&password=' + email + '&citta=' + citta;

    i valori presi da un form.
    C'era un errore nel passaggio del form l'ho corretto

    var dataString = 'nome='+ nome + '&cognome=' + cognome +'&username=' + username + '&password=' + password + '&email=' + email + '&citta=' + citta;


    ma da sempre lo stesso errore

  10. #10
    Fatal error: require_once() [function.require]: Failed opening required '/classes/Mysql.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/member /includes/ValidUserAdd.php on line 2<br / ma non capisco xkè i file si trovano in quelle path.

    E' buona norma anzi è la norma
    prima di utilizzare ajax lo script deve
    essere fruibile anche con js disabilitato.


    Copme poi pretendere che lo script
    funzioni con un errore del genere.


    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

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.