Login   Register  
PHP Classes
elePHPant
Icontem

File: activate_password.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Olaf Lederer  >  Access user Class  >  activate_password.php  >  Download  
File: activate_password.php
Role: Application script
Content type: text/plain
Description: Form where to submit a new (lost) password
Class: Access user Class
Site user registration and page access restriction
Author: By
Last change: added fields and variables for the new password check
Date: 9 years ago
Size: 2,368 bytes
 

Contents

Class file image Download
<?php 
include($_SERVER['DOCUMENT_ROOT']."/classes/access_user/access_user_class.php"); 

$act_password = new Access_user;

if (isset(
$_GET['activate']) && isset($_GET['id'])) { // this two variables are required for activating/updating the account/password
    
if ($act_password->check_activation_password($_GET['activate'], $_GET['id'])) { // the activation/validation method 
        
$_SESSION['activation'] = $_GET['activate']; // put the activation string into a session or into a hdden field
        
$_SESSION['id'] = $_GET['id']; // this id is the key where the record have to be updated with new pw
    

}
if (isset(
$_POST['Submit'])) {
    if (
$act_password->activate_new_password($_POST['password'], $_POST['confirm'], $_SESSION['activation'], $_SESSION['id'])) { // this will change the password
        
unset($_SESSION['activation']);
        unset(
$_SESSION['id']); // inserts new password only ones!
    
}
    
$act_password->user $_POST['user']; // to hold the user name in this screen (new in version > 1.77)

$error $act_password->the_msg;
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example new Passwort activation</title>
</head>

<body>
<?php if (isset($_SESSION['activation'])) { ?>
<h2>Enter your new password:</h2>
<p>Enter here your new password, (login: <b><?php echo $act_password->user?></b>).</p>
<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  <label for="password"><b>(new)</b> Password:</label>
  <input type="password" name="password" value="<?php echo (isset($_POST['password'])) ? $_POST['password'] : ""?>">
  <label for="confirm">Confirm password:</label>
  <input type="password" name="confirm" value="<?php echo (isset($_POST['confirm'])) ? $_POST['confirm'] : ""?>">
  <input type="hidden" name="user" value="<?php echo $act_password->user?>">
  <input type="submit" name="Submit">
</form>
<?php } else { ?>
<h2>Att. !</h2>
<?php ?>
<p style="color:#FF0000;"><b><?php echo (isset($error)) ? $error "&nbsp;"?></b></p>
<p>&nbsp;</p>
<!-- Notice! you have to change this links here, if the files are not in the same folder -->
<p><a href="<?php echo $act_password->login_page?>">Login</a></p>
</body>
</html>