Visualizzazione dei risultati da 1 a 5 su 5

Discussione: controllo attivazione

  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2006
    Messaggi
    656

    controllo attivazione

    allora,

    durante l'scrizione invio un codice di conferma all'indirizzo email per attivare l'account.

    qui tutto ok.

    il problema è quando devo fare il login.


    prima di effettuare i select del username e password e poi creare la sessione vorrei vedere se il campo attvato, per quel username è uguale a si(cioe che è attivto).

    ho provato con un if ma mi da sempre che l'acccount non è attivato.

    un aiuto??

    Codice PHP:
    <?
    # FileName="Connection_php_mysql.htm"
    # Type="MYSQL"
    # HTTP="true"
    $hostname_love "xxx";
    $database_love "xxx";
    $username_love "xxx";
    $password_love "xxxxx";
    $love mysql_pconnect($hostname_love$username_love$password_love) or trigger_error(mysql_error(),E_USER_ERROR); $user="$_POST[username]";
    $r2 "$row_Recordset1[attivato]";
    $r "si";
    ?><?
    mysql_select_db
    ($database_love$love);
    $query_Recordset1 "SELECT attivato FROM utenti WHERE username = '$user'";
    $Recordset1 mysql_query($query_Recordset1$love) or die(mysql_error());
    $row_Recordset1 mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 mysql_num_rows($Recordset1);

    ?>
    <?php

    {


       if(
    $r==$r2)
       {
          
          
          
          
          
    // *** Validate request to login to this site.
    if (!isset($_SESSION)) {
      
    session_start();
    }

    $loginFormAction $_SERVER['PHP_SELF'];
    if (isset(
    $_GET['accesscheck'])) {
      
    $_SESSION['PrevUrl'] = $_GET['accesscheck'];
    }

    if (isset(
    $_POST['username'])) {
      
    $loginUsername=$_POST['username'];
      
    $password=$_POST['password'];
      
    $MM_fldUserAuthorization "";
      
    $MM_redirectLoginSuccess "welcome.php";
      
    $MM_redirectLoginFailed "error.php";
      
    $MM_redirecttoReferrer false;
      
    mysql_select_db($database_love$love);
      
      
    $LoginRS__query=sprintf("SELECT username, password FROM utenti WHERE username=%s AND password=%s",
        
    GetSQLValueString($loginUsername"text"), GetSQLValueString($password"text")); 
       
      
    $LoginRS mysql_query($LoginRS__query$love) or die(mysql_error());
      
    $loginFoundUser mysql_num_rows($LoginRS);
      if (
    $loginFoundUser) {
         
    $loginStrGroup "";
        
        
    //declare two session variables and assign them
        
    $_SESSION['MM_Username'] = $loginUsername;
        
    $_SESSION['MM_UserGroup'] = $loginStrGroup;          

        if (isset(
    $_SESSION['PrevUrl']) && false) {
          
    $MM_redirectLoginSuccess $_SESSION['PrevUrl'];    
        }
        
    header("Location: " $MM_redirectLoginSuccess );
      }
      else {
        
    header("Location: "$MM_redirectLoginFailed );
      }
    }
          
          
          
       }
       else
       {
          print 
    "<html><head><title>Account Non Attivato</title></head> <body>
    <BR
    <div style=\"font-family:verdana,tahoma\" align=\"center\">Il codice d'attivazione non è corretto.
    Contatta il  <a href=\"mailto:help@xxx.net\">supporto utenti</a>/div><body></html>"
    ;
       }

    }

    ?>
    <?php
    mysql_free_result
    ($Recordset1);
    ?>

  2. #2
    Scusa, ma quando all'inizio dichiari

    $r2 = "$row_Recordset1[attivato]";


    la variabile $row_Recordset1 non è stata ancora inizializzata quindi $r2 sarà una stringa vuota.

  3. #3
    $r2 va messa dopo $row_Recordset1 = mysql_fetch_assoc($Recordset1);

    ed inoltre $r2 = $row_Recordset1['attivato'];

  4. #4
    Utente di HTML.it
    Registrato dal
    Nov 2006
    Messaggi
    656
    ho fatto cosi ma niente.
    Codice PHP:
    <?
    # FileName="Connection_php_mysql.htm"
    # Type="MYSQL"
    # HTTP="true"
    $hostname_love "xxx";
    $database_love "lxxx";
    $username_love "xxxx";
    $password_love "xxxxx";
    $love mysql_pconnect($hostname_love$username_love$password_love) or trigger_error(mysql_error(),E_USER_ERROR); 
    ?>
    <?
    mysql_select_db
    ($database_love$love);
    $query_Recordset1 "SELECT attivato FROM utenti WHERE username = '$user'";
    $Recordset1 mysql_query($query_Recordset1$love) or die(mysql_error());
    $row_Recordset1 mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 mysql_num_rows($Recordset1);

    ?>
    <?php
    $r2 
    "$row_Recordset1[attivato]";
    $user="$_POST[username]";
    $r "si";?>
    <?



       
    if($r==$r2)
       {
          
          
          
          
          
    // *** Validate request to login to this site.
    if (!isset($_SESSION)) {
      
    session_start();
    }

    $loginFormAction $_SERVER['PHP_SELF'];
    if (isset(
    $_GET['accesscheck'])) {
      
    $_SESSION['PrevUrl'] = $_GET['accesscheck'];
    }

    if (isset(
    $_POST['username'])) {
      
    $loginUsername=$_POST['username'];
      
    $password=$_POST['password'];
      
    $MM_fldUserAuthorization "";
      
    $MM_redirectLoginSuccess "welcome.php";
      
    $MM_redirectLoginFailed "error.php";
      
    $MM_redirecttoReferrer false;
      
    mysql_select_db($database_love$love);
      
      
    $LoginRS__query=sprintf("SELECT username, password FROM utenti WHERE username=%s AND password=%s",
        
    GetSQLValueString($loginUsername"text"), GetSQLValueString($password"text")); 
       
      
    $LoginRS mysql_query($LoginRS__query$love) or die(mysql_error());
      
    $loginFoundUser mysql_num_rows($LoginRS);
      if (
    $loginFoundUser) {
         
    $loginStrGroup "";
        
        
    //declare two session variables and assign them
        
    $_SESSION['MM_Username'] = $loginUsername;
        
    $_SESSION['MM_UserGroup'] = $loginStrGroup;          

        if (isset(
    $_SESSION['PrevUrl']) && false) {
          
    $MM_redirectLoginSuccess $_SESSION['PrevUrl'];    
        }
        
    header("Location: " $MM_redirectLoginSuccess );
      }
      else {
        
    header("Location: "$MM_redirectLoginFailed );
      }
    }
          
          
          
       }
       else
       {
          print 
    "<html><head><title>Account Non Attivato</title></head> <body>
    <BR
    <div style=\"font-family:verdana,tahoma\" align=\"center\">Il codice d'attivazione non è corretto.
    Contatta il  <a href=\"mailto:help@xxx.net\">supporto utenti</a>/div><body></html>"
    ;
       }


    ?>
    <?php
    mysql_free_result
    ($Recordset1);
    ?>

  5. #5
    Innanzitutto perché apri e chiudi in continuazione i tag php cioé <?php e ?>

    Quando scrivi:

    username_love = "xxxx";
    $password_love = "xxxxx";
    $love = mysql_pconnect($hostname_love, $username_love, $password_love) or trigger_error(mysql_error(),E_USER_ERROR);
    ?>
    <?
    mysql_select_db($database_love, $love);
    $query_Recordset1 = "SELECT attivato FROM utenti WHERE username = '$user'";
    $Recordset1 = mysql_query($query_Recordset1, $love) or die(mysql_error());

    è inutile che chiudi con ?> e subito dopo riapri <? è sempre codice php!!!

    Poi, perché ti ostini a scrivere:

    $r2 = "$row_Recordset1[attivato]";
    $user="$_POST[username]";

    scrivi:

    $r2 = $row_Recordset1['attivato'];
    $user=$_POST['username'];


    Qui:
    $query_Recordset1 = "SELECT attivato FROM utenti WHERE username = '$user'";

    hai fatto lo stesso errore di prima hai usato $user ma questa l'hai definita dopo!

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.