Salta al contenuto
  • CATEGORIES
  • La Community Connect.gt
  • Presentati alla Community
  • News Ufficiali da Connect.gt
  • Internet News
  • A Scuola Di
  • Digital Marketing
  • Intelligenza Artificiale
  • SEO & GEO
  • Web Marketing e Content
  • Google Analytics e Web Analytics
  • Google Ads & Advertising
  • YouTube
  • TikTok, Instagram e altri Social
  • Google Adsense, Affiliazioni e Guadagno
  • E-Commerce
  • Coding e Sistemistica
  • Help Center: consigli per il tuo progetto
  • Hosting e Cloud
  • Coding
  • CMS & Piattaforme Self-Hosted
  • Annunci e Collaborazioni
  • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
  • Collaborazioni WEB e Lavoro: offro e cerco
  • Impresa, Fisco e Leggi
  • Consulenza Legale e Professioni Web
  • Consulenza Fiscale, Imprese, Startup e P.Iva
  • Gli Off Topic
  • PC, Smartphone e altri Hardware
  • Tutti i Software
  • GT Fetish Cafè
  • Discussioni
  • 0 Non letti 0
  • Recenti
  • Hashtag
  • Popolare
  • Utenti
  • Privacy
  • Termini e condizioni
  • © 2026 Search On Media Group S.r.l.
Collassa
Connect.gt
Il network Search On
Connect.gt WMF AI Festival Accademia Advanced SEO Tool AgentCy Social Media Strategies Search Tech
Registrati Accedi
Connect.gt
Stream Interest Categorie Hashtag
  1. La community italiana di SEO, marketing digitale e AI
  2. Categorie
  3. Coding e Sistemistica
  4. Coding
  5. session_start

session_start

Pianificato Fissato Bloccato Spostato Coding
3 Post 2 Autori 930 Visualizzazioni 1 Seguito
  • Da Vecchi a Nuovi
  • Da Nuovi a Vecchi
  • Più Voti
Rispondi
  • Risposta alla discussione
Effettua l'accesso per rispondere
Questa discussione è stata eliminata. Solo gli utenti con diritti di gestione possono vederla.
  • R
    R
    regedit
    scritto su ultima modifica di
    User Newbie 0
    #1
    session_start

    chi mi aiuta a risolvere questi errori?:(
    Notice: Undefined index: username in y:\home\login\www\index.php on line 88
    Notice: Undefined index: username in y:\home\login\www\index.php on line 93

    Warning: Cannot modify header information - headers already sent by (output started at y:\home\login\www\index.php:88) in y:\home\login\www\index.php on line 143

    il codice è:
    <?php

    define('INCLUDE_CHECK',true);

    require 'connect.php';
    require 'functions.php';
    // Those two files can be included only if INCLUDE_CHECK is defined

    session_start();

    session_name('tzLogin');
    // Starting the session

    session_set_cookie_params(27246060);
    // Making the cookie live for 2 weeks

    if(isset($_SESSION['id']) && !isset($_COOKIE['tzRemember']) && !isset($_SESSION['rememberMe']))
    {
    // If you are logged in, but you don't have the tzRemember cookie (browser restart)
    // and you have not checked the rememberMe checkbox:

    **$_SESSION = array();**
    **session_destroy();**
    
    **// Destroy the session**
    

    }

    if(isset($_GET['logoff']))
    {
    $_SESSION = array();
    session_destroy();

    **header("Location: index.php");**
    **exit;**
    

    }

    if(isset($_POST['submit']) && $_POST['submit']=='Login')
    {
    // Checking whether the Login form has been submitted

    **$err = array();**
    **// Will hold our errors**
    
    
    **if(!$_POST['username'] || !$_POST['password'])**
        **$err[] = 'All the fields must be filled in!';**
    
    **if(!count($err))**
    **{**
        **$_POST['username'] = mysql_real_escape_string($_POST['username']);**
        **$_POST['password'] = mysql_real_escape_string($_POST['password']);**
        **$_POST['rememberMe'] = (int)$_POST['rememberMe'];**
        
        **// Escaping all input data**
    
        **$row = mysql_fetch_assoc(mysql_query("SELECT id,usr FROM tz_members WHERE usr='{$_POST['username']}' AND pass='".md5($_POST['password'])."'"));**
    
        **if($row['usr'])**
        **{**
            **// If everything is OK login**
            
            **$_SESSION['usr']=$row['usr'];**
            **$_SESSION['id'] = $row['id'];**
            **$_SESSION['rememberMe'] = $_POST['rememberMe'];**
            
            **// Store some data in the session**
            
            **setcookie('tzRemember',$_POST['rememberMe']);**
        **}**
        **else $err[]='Wrong username and/or password!';**
    **}**
    
    **if($err)**
    **$_SESSION['msg']['login-err'] = implode('<br />',$err);**
    **// Save the error messages in the session**
    
    **header("Location: index.php");**
    **exit;**
    

    }
    else if(isset($_POST['submit']) && $_POST['submit']=='Register')
    {
    // If the Register form has been submitted

    **$err = array();**
    
    **if(strlen($_POST['username'])<4 || strlen($_POST['username'])>32)**
    **{**
        **$err[]='Your username must be between 3 and 32 characters!';**
    **}**
    
    **if(preg_match('/[^a-z0-9\-\_\.]+/i',$_POST['username']))**
    **{**
        **$err[]='Your username contains invalid characters!';**
    **}**
    
    **if(!checkEmail($_POST['email']))**
    **{**
        **$err[]='Your email is not valid!';**
    **}**
    
    **if(!count($err))**
    **{**
        **// If there are no errors**
        
        **$pass = substr(md5($_SERVER['REMOTE_ADDR'].microtime().rand(1,100000)),0,6);**
        **// Generate a random password**
        
        **$_POST['email'] = mysql_real_escape_string($_POST['email']);**
        **$_POST['username'] = mysql_real_escape_string($_POST['username']);**
        **// Escape the input data**
        
        
        **mysql_query("    INSERT INTO tz_members(usr,pass,email,regIP,dt)**
                        **VALUES(**
                        
                            **'".$_POST['username']."',**
                            **'".md5($pass)."',**
                            **'".$_POST['email']."',**
                            **'".$_SERVER['REMOTE_ADDR']."',**
                            **NOW()**
                            
                        **)");**
        
        **if(mysql_affected_rows($link)==1)**
        **{**
            **send_mail(    '[email protected]',**
                        **$_POST['email'],**
                        **'Registration System Demo - Your New Password',**
                        **'Your password is: '.$pass);**
    
            **$_SESSION['msg']['reg-success']='We sent you an email with your new password!';**
        **}**
        **else $err[]='This username is already taken!';**
    **}**
    
    **if(count($err))**
    **{**
        **$_SESSION['msg']['reg-err'] = implode('<br />',$err);**
    **}**    
    
    **header("Location: index.php");**
    **exit;**
    

    }

    $script = '';

    if($_SESSION['msg'])
    {
    // The script below shows the sliding panel on page load

    **$script = '**
    **<script type="text/javascript">**
    
        **$(function(){**
        
            **$("div#panel").show();**
            **$("#toggle a").toggle();**
        **});**
    
    **</script>';**
    

    }
    ?>

    1 Risposta Ultima Risposta
    Miglior risposta 0
    0
    • A
      A
      antoniog2
      scritto su ultima modifica di
      User Attivo 0
      #2

      Perchè fai riavviare il browser per settare il cookie?
      L'utente potrebbe considerarla una operazione malevola da parte di un cracker. Ma è una tua scelta. Io mostrerei una popup che richiede i dati da inserire nel cookie, per esempio.
      Forse fai eseguire session_destroy() prima di header("Location: index.php")

      1 Risposta Ultima Risposta
      Miglior risposta 0
      0
      • A
        A
        antoniog2
        scritto su ultima modifica di
        User Attivo 0
        #3

        Per il cookie: ricorri al cookie di sessione incorporando SID nella tua istruzione e se non puoi utilizzare il cookie nella macchina dell'utente in quanto non presente.
        Devi quindi usare $_COOKIE per verificare se tutti i valori che vuoi verificarne l'esiostenza nel cookie sulla macchina del tuo utente.
        Vedi il manuale online di PHP.

        1 Risposta Ultima Risposta
        Miglior risposta 0
        0

        Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.

        Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.

        Con il tuo contributo, questo post potrebbe essere ancora migliore 💗

        Registrati Accedi
        Rispondi
        • Risposta alla discussione
        Effettua l'accesso per rispondere
        • Da Vecchi a Nuovi
        • Da Nuovi a Vecchi
        • Più Voti


        • Accedi

        • Non hai un account? Registrati

        • Accedi o registrati per effettuare la ricerca.
        • Primo post
          Ultimo post
        Home Accedi Registrati
        Menu
        • CATEGORIES
        • La Community Connect.gt
        • Presentati alla Community
        • News Ufficiali da Connect.gt
        • Internet News
        • A Scuola Di
        • Digital Marketing
        • Intelligenza Artificiale
        • SEO & GEO
        • Web Marketing e Content
        • Google Analytics e Web Analytics
        • Google Ads & Advertising
        • YouTube
        • TikTok, Instagram e altri Social
        • Google Adsense, Affiliazioni e Guadagno
        • E-Commerce
        • Coding e Sistemistica
        • Help Center: consigli per il tuo progetto
        • Hosting e Cloud
        • Coding
        • CMS & Piattaforme Self-Hosted
        • Annunci e Collaborazioni
        • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
        • Collaborazioni WEB e Lavoro: offro e cerco
        • Impresa, Fisco e Leggi
        • Consulenza Legale e Professioni Web
        • Consulenza Fiscale, Imprese, Startup e P.Iva
        • Gli Off Topic
        • PC, Smartphone e altri Hardware
        • Tutti i Software
        • GT Fetish Cafè
        • Discussioni
        • Non letti 0
        • Recenti
        • Hashtag
        • Popolare
        • Utenti
        • Privacy
        • Termini e condizioni
        • © 2026 Search On Media Group S.r.l.