• User Attivo

    resetta password dimenticata

    buongiorno sto tentando di resettare la password dimenticata salvata in md5 usando PHPMailer-master ma sembra se ho capito bene che Google non accetta più questa funzione infatti mi da questo errore:
    qualcosa non ha funzionato: SMTP Error: Could not connect to SMTP host.Failed to connect to serverSMTP server error:Failed to connect server SMTP code: 99 Additional SMTP info: Cannot assign requested addres.
    Se la password la salvo in chiaro ( sconsigliato ) non ho problemi ma come posso resettare via mail la password dimenticata? e se do l'incarico ad un programmatore quanto mi costa? 😞


    I 1 Risposta
  • User Attivo

    ciao e buona serata come ripeto sto provato a resettare la password via mail ho provato di nuovo ma mi da il seguente errore:
    [26-Apr-2023 19:08:37 UTC] PHP Warning: session_start(): Session cannot be started after headers have already been sent in /home/epntzhid/public_html/cambiapassword/index.php on line 62
    posto il code

    <?php
    include_once('connection.php');
    if(isset($_REQUEST['password']))
    {
      $email = $_REQUEST['email'];
      $check_email = mysqli_query($connection,"select email from users where email='$email'");
      $res = mysqli_num_rows($check_email);
      if($res>0)
      {
        $message = '<div>
         <p><b>Hello!</b></p>
         <p>You are recieving this email because we recieved a password reset request for your account.</p>
         <br>
         <p><button class="btn btn-primary"><a href="https://amministrazione.netsons.org/cambiapassword/passwordreset.php?secret='.base64_encode($email).'">Reset Password</a></button></p>
         <br>
         <p>If you did not request a password reset, no further action is required.</p>
        </div>';
    
    include_once("PHPMailer-5.2-stable/class.phpmailer.php");
    include_once("PHPMailer-5.2-stable/class.smtp.php");
    $email = $email; 
    $mail = new PHPMailer;
    $mail->IsSMTP();
    $mail->SMTPAuth = true;                 
    $mail->SMTPSecure = "tls";      
    $mail->Host = 'smtp.gmail.com';
    $mail->Port = 587; 
    $mail->Username = "[email protected]";
    $mail->Password = "***********";
    $mail->FromName = "Tech Area";
    $mail->AddAddress($email);
    $mail->Subject = "Reset Password";
    $mail->isHTML( TRUE );
    $mail->Body =$message;
    if($mail->send())
    {
      $msg = "We have e-mailed your password reset link!";
    }
    }
    else
    {
      $msg = "We can't find a user with that email address";
    }
    }
    
    ?>
    <body>
    <div class="container">  
        <div class="table-responsive">  
        <h3 align="center">Forgot Password</h3><br/>
        <div class="box">
         <form id="validate_form" method="post" >  
           <div class="form-group">
           <label for="email">Email Address</label>
           <input type="text" name="email" id="email" placeholder="Enter Email" required 
           data-parsley-type="email" data-parsley-trigg
           er="keyup" class="form-control" />
          </div>
          <div class="form-group">
           <input type="submit" name="password" value="Send Password Reset Link" class="btn btn-success" />
           </div>
           
           <p class="error"><?php if(!empty($msg)){ echo $msg; } ?></p>
         </form>
         </div>
       </div>  
      </div>
    </body>
    </