Poll

Do you think this should be an available option?

Yes
No

Author Topic: Forgot Password option  (Read 8062 times)

framirez

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
    • View Profile
    • Email
Forgot Password option
« on: June 24, 2009, 00:03:58 »
Is it possible to get a forgot my password option in QueueMetrics? We are currently running version 1.4.7.1

Would it be possible to script it out on our end? If yes what would I be looking at as far as scripting languages and details to get it to work with the existing software?

Any help would be greatly appreciated.

Thanks,

Francisco Ramirez

QueueMetrics

  • Loway
  • Hero Member
  • *
  • Posts: 2999
  • Karma: 39
    • View Profile
    • QueueMetrics
Re: Forgot Password option
« Reply #1 on: June 25, 2009, 12:02:08 »
If a number of people are interested, we could add this in.
 

framirez

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
    • View Profile
    • Email
Re: Forgot Password option
« Reply #2 on: June 25, 2009, 21:34:33 »
I worked on getting the following. Haven't tested it yet tho, will be doing that tomorrow and reporting back...

<html>
<form method="post" action="forgot_password.php">

<table border="0" width="100%" color="gray">
<tr><td align="right">
<img src="sm_qm_logo.gif">
</td></tr>
</table>

<h1>Forgot your password?</h1> <p />

Enter your Username: <br/>

<input type="text" name="username" size="50" maxlength="50"/>

<input type="submit" value="Send my password" />

</form>
</html>


<?php

$username = $_POST['username'];

$dbname = ""dbname"";
$conn = mysql_connect ('localhost','"user"','"password"') or
die ('cannot connect to database error: '.mysql_error());
mysql_select_db ($dbname);


if($username != "")
{

$result = mysql_query("select * from users where name = '$username'") or die(mysql_error());
$count=mysql_num_rows($result);

if($count != 1){
   echo "no user with this username";
   $alert = "We're sorry, but we could not find a user with that username.";
}
else {
   echo "email with password was sent";
   $alert = "Your username and password have been emailed to you.";

   $row = mysql_fetch_array($result, MYSQL_ASSOC);
   $username = $row['username'];
   $password = $row['password'];
   $msg = "Your login information is:\n\n";
   $msg .= "Username: $username\n";
   $msg .= "Password: $password\n";
   mail($user_email, "Login Information", $msg, "From:helpdesk@cashnetusa.com");
}
} else {
echo "user email not set"; }
?>

Please vote so we can get this as an out of the box feature.

QueueMetrics

  • Loway
  • Hero Member
  • *
  • Posts: 2999
  • Karma: 39
    • View Profile
    • QueueMetrics
Re: Forgot Password option
« Reply #3 on: June 30, 2009, 14:52:49 »
yes I think this would work.
If you don't mind, I would add this to the user-contribuited scripts for QM.

framirez

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
    • View Profile
    • Email
Re: Forgot Password option
« Reply #4 on: July 01, 2009, 02:23:45 »
I want to add it, however; I am working on getting a more secure way to only ask for the username and have the script add the @domain to create the send to email...

QueueMetrics

  • Loway
  • Hero Member
  • *
  • Posts: 2999
  • Karma: 39
    • View Profile
    • QueueMetrics
Re: Forgot Password option
« Reply #5 on: July 06, 2009, 09:42:44 »
Please do...

framirez

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
    • View Profile
    • Email
Re: Forgot Password option
« Reply #6 on: August 24, 2009, 22:00:33 »
Ok guys. Sorry for the long delay.. Here we go.... Remember this is a really dirty way to do this, maybe someone can create a better setup, but this is how I got it to work.

The barebone html:

Code: [Select]
<html>
<head>
   <title>I Forgot My Password!</title>
<!-- Start CSS -->

   <STYLE TYPE="text/css">
      label{ width: 4em; float: left; text-align: right; margin-right: 0.5em; display: block }
      .submit input{ margin-left: 4.5em; }
      input{ color: #000; background: #E1F0F7; border: 1px solid #FF9900 }
      .submit input{ color: #000; background: #FF9900; border: 2px outset #d7b9c9 }
      fieldset{ border: 1px solid #FF9900; width: 20em }
      legend{ color: #fff; background: #3089C5; border: 1px solid #3089C5; padding: 2px 6px }
      body { color: #000; background: #fff; font-size="12";}
   </STYLE

<!-- End CSS -->
</head>

<body>

<!-- Start top area -->

   <img src="http://demo.loway.ch/queuemetrics-livedemo/img/sm_qm_logo.gif" align ="right">

     <p>&nbsp;</p><hr>
   <p>Please enter your username and press the submit button to have your password emailed to you.<p>
     <p>&nbsp;</p>

<!-- End top area -->

<!-- Start form -->

   <form method="post" action="passwd.php" >
      <fieldset>

       <legend>Forgot Password</legend>
       <label for="username">Username:</label><br />
       <input type="text"  id="username" name="username"  />
    <br />
       <label for="submit">&nbsp;</label><br />
       <input id="submit" name="submit" type="submit" value="submit" />
      </fieldset>
   </form>

<!-- End form -->
</html>


The php

Code: [Select]
<?php

error_reporting
(E_ALL);

$username $_POST['username'];

if (!
preg_match('/^[a-zA-Z].*[0-9]*$/',$username)) {
    echo 
"Invalid Entry! Please go back and try again. ";
    exit;
}

$dbname "queuemetrics";
$conn mysql_connect ('localhost','login_name','password') or
die (
'cannot connect to database error: '.mysql_error());
mysql_select_db ($dbname$conn);

if(
$username != ""){

   
$sql 'select PASSWORD from arch_users where login = "' $username .'";';
   
$result mysql_query($sql$conn) or die(mysql_error());
   
$count=mysql_num_rows($result);
   switch (
$count) {
      case 
0;
         echo 
"We're sorry, but we could not find that username.";
         break;
      case 
1;
         
$userpass="";
         while (
$row mysql_fetch_assoc($result)) {
            
$userpass=$row['PASSWORD'];
         }
         
$subject  "Your Queuemetrics Login Information";
         
$message  "Your Password for logging into queuemetrics is:\n\n";
         
$message .= "Password: $userpass\n";
         
$to       "$username@domain.com";
         
$header     'From: Helpdesk' "\r\n" 'Reply-To: no-reply@domain.com' "\r\n";


      if (
mail($to$subject$message$header)){
         echo 
"Your Login credentials have been emailed to you.";
      }
      else {
         echo 
"We're sorry, but we could not email your password because of a problem.";
      }

   }
}

else{
   echo 
"No username provided";
}
?>


Creating the shortcut on the login page:

In the autenticazione.jsp file, search for this line:   

Code: [Select]
<%= oH.button( oDec.k("logon_btn") + " &raquo; ", true, "", "qm_autentica", "" ) %>
Right after that make the following entry:

Code: [Select]
<p>&nbsp;</p>
<a href="http://localhost/apache2-default/passwd.html"><small>Forgot Password</small></a>



Hope this helps someone as much as it helped us.

QueueMetrics

  • Loway
  • Hero Member
  • *
  • Posts: 2999
  • Karma: 39
    • View Profile
    • QueueMetrics
Re: Forgot Password option
« Reply #7 on: August 24, 2009, 23:21:07 »
Can I post this as a part of the Open QueueMetrics Add-ons collection?

framirez

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
    • View Profile
    • Email
Re: Forgot Password option
« Reply #8 on: August 26, 2009, 00:51:09 »
You most definitely can, it would be an honor to contribute to this software. However I must point out that when setting the shortcut on the login page, it may have to be edited to work with the system it's being put on. That is how I had my system setup.