Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 11
  1. #1

    [PHP] Problema con una funzione

    Ciao a tutti,

    non riesco a fare in modo che al controllo del login se corretto mi inserisce dei dati nel db,
    in poche parole fa il redirect alla pagina member ma non mi prende la funzione che appunto mi inserisca i dati, qualcuno sa dirmi dove sbaglio?

    Codice PHP:
    if(mysql_num_rows($query) > 0
    {
                
    $lastactive time();
                    
    $sql "UPDATE tbl_settings SET set_useronline = '1', set_lastactive = '$lastactive' WHERE tbl_settings.lg_id =                       '$userid'";
                    
    $query mysql_query($sql) or die ("Errore nel aggiornare la tabella settings " mysql_error());
        
    $_SESSION['auth'] = 1;
        
    $_SESSION['username'] = $username;
        
    header("Location: member.php?uid=$userid&ug=$usergroup&page=impostazioni");
        
    adduserStat(); // Qui il problema!!!!!
                
    exit(); 
    PHP THE BEST

  2. #2
    mi sorge un dubbio, ma dentro a una funzione posso richiamare un'altra funzione?
    PHP THE BEST

  3. #3
    di poterlo fare lo puoi fare

    se riesci posta la funzione che vediamo


    @edit
    ma non ti conviene creare un file tipo sql.php dove metti tute le query di inserimento , modifica,cancellazione , ecc...
    3/6/2003 è morto l'angelo della mia vita..
    www.markwebinformatica.net
    My BLOG

  4. #4
    Codice PHP:
    if(mysql_num_rows($query) > 0)
    {
                
    $lastactive time();
                    
    $sql "UPDATE tbl_settings SET set_useronline = '1', set_lastactive = '$lastactive' WHERE tbl_settings.lg_id =                       '$userid'";
                    
    $query mysql_query($sql) or die ("Errore nel aggiornare la tabella settings " mysql_error());
        
    $_SESSION['auth'] = 1;
        
    $_SESSION['username'] = $username;
        
    adduserStat(); // Esegui la funzione prima di inviare l'header! <=========
        
    header("Location: member.php?uid=$userid&ug=$usergroup&page=impostazioni");
                exit(); 
    HTH
    Zappa
    [PC:Presario 2515EU][Cpu:P4@2.3GHz][Ram: 512M][HDU:80G@5400 RPM]
    [Wireless:LinkSys][OS: Ubuntu 9.04 - Jaunty Jackalope]

  5. #5
    Grazie per le risposte,

    intendi fare una pagina dove metto tutte le richieste per il db update inser e delete e poi le richiamo al momento del bisogno?

    Sto imparando e mi accorgo ogni volta che non sono oredinato nel programmare, ma ogni volta che lo faccio sistemo per il meglio hehehe !!


    Alla fine ho risolto cosi al momento che si logga l'utente nella pagina member faccio eseguire la funzione:

    Codice PHP:
    function adduserStat()
    {
                
    $uid $_GET['uid'];
                
    $ip $_SERVER['REMOTE_ADDR'];
                
    $agent $_SERVER['HTTP_USER_AGENT'];
                
    $host $_SERVER['HTTP_HOST'];
                
    $url $_SERVER['REQUEST_URI'];
                
    $time time();


        
    $sql"SELECT * FROM tbl_stats WHERE lg_id = $uid";
        
    $query mysql_query($sql) or die (mysql_error());
        
    $result mysql_fetch_assoc($query);
        
    $numrows mysql_num_rows($query);
        echo 
    $numrows;
    if(
    $numrows == 0
            {
                
    $sql "INSERT INTO tbl_stats (lg_id, sta_ip, sta_agent, sta_host, sta_url, sta_time) VALUE ('$uid', '$ip', '$agent', '$host', '$url', '$time')";
                
    $query mysql_query($sql) or die (mysql_error());
            } 
            else 
            {
                
    $sql "UPDATE tbl_stats SET lg_id = '$uid', sta_ip = '$ip', sta_agent = '$agent', sta_host = '$host', sta_url = '$url', sta_time = '$time' WHERE lg_id = $uid";
                
    $query mysql_query($sql) or die (mysql_error());
            }

    E funziona come voglio io!!!

    Consigli sono sembre i beneveuti!!

    Grazie Michel
    PHP THE BEST

  6. #6
    @ Considerazione personale @

    Avere una pagina che fa da cuore sql secondo me lo rende più gestibile in qunto tramite GET richiami il caso che vuoi ecco un esempio :

    link ---> sql.php?fare=cancella_utente


    nella pagina tu hai una serie di if tipo...
    Codice PHP:
    if($_GET['fare']=='inserisci_utente')
    {

      
    $uid $_GET['uid'];
                
    $ip $_SERVER['REMOTE_ADDR'];
                
    $agent $_SERVER['HTTP_USER_AGENT'];
                
    $host $_SERVER['HTTP_HOST'];
                
    $url $_SERVER['REQUEST_URI'];
                
    $time time();


        
    $sql"SELECT * FROM tbl_stats WHERE lg_id = $uid";
        
    $query mysql_query($sql) or die (mysql_error());
        
    $result mysql_fetch_assoc($query);
        
    $numrows mysql_num_rows($query);
        echo 
    $numrows;
    if(
    $numrows == 0)
            {
                
    $sql "INSERT INTO tbl_stats (lg_id, sta_ip, sta_agent, sta_host, sta_url, sta_time) VALUE ('$uid', '$ip', '$agent', '$host', '$url', '$time')";
                
    $query mysql_query($sql) or die (mysql_error());
            }
            else
            {
                
    $sql "UPDATE tbl_stats SET lg_id = '$uid', sta_ip = '$ip', sta_agent = '$agent', sta_host = '$host', sta_url = '$url', sta_time = '$time' WHERE lg_id = $uid";
                
    $query mysql_query($sql) or die (mysql_error());
            }
    }


    }

    if(
    $_GET['fare']=='modifica_utente')
    {
    }

    if(
    $_GET['fare']=='cancella_utente')
    {

    3/6/2003 è morto l'angelo della mia vita..
    www.markwebinformatica.net
    My BLOG

  7. #7
    Cioé se ho capito bene intendi un file php con solo istruzioni sql? Per esempio:

    file sql.php


    if($_GET['query'] == "update")
    {
    ...
    }


    if($_GET['query'] == "delete")
    {
    ...
    }

    if($_GET['query'] == "insert")
    {
    ...
    }


    if($_GET['query'] == "edituser")
    {
    ...
    }

    e via dicendo ho capito bene?
    PHP THE BEST

  8. #8
    si ma devi scriverle dentro le parentesi graffe i comandi sql se vuoi ti posto un mio file sql.php

    cosi come esempio
    3/6/2003 è morto l'angelo della mia vita..
    www.markwebinformatica.net
    My BLOG

  9. #9
    Ok allora pian pianino comincerò a modificare il tutto, o vedrò di farlo nel prossimo sito che farò!!

    PHP THE BEST

  10. #10
    kk posta che vedo!
    PHP THE BEST

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.