Author Topic: Let user change password  (Read 551 times)

0 Members and 1 Guest are viewing this topic.

Offline winracer

  • Development Team
  • Pro Member
  • *******
  • Posts: 446
  • Karma: 3
    • View Profile
    • helpmewithperl.com
  • Script Version: 1.0+
Let user change password
« on: March 13, 2010, 04:22:42 AM »
4 steps to this.

1st
edit lang/en-gb.inc.php

add
Code: [Select]
$smarty->assign('LAN_210', 'Change Login Password');

2nd

edit memberbar.tpl

add
under <li><a href="favorite.php">{$LAN_110}[/url]</li> or where you want it.
Code: [Select]
<li><a href="changepassword.php">{$LAN_210}</a></li>



3rd. create new file changepassword.tbl
put this code in it
Code: [Select]
{include file="header.tpl"}
<div id="container">
<!--Left Column Start-->
<div id="main-wrapper">
<!--Left Column Inner Start-->
<div id="content">
<h2>Change password! <? echo $_SESSION['email']; ?> User {$user} <? echo $userID ?> </h2>
<form method="post" action="changepassword.php">
    <p class="style3"><label for="password1"">New password:</label>
    <input type="password" title="Please enter a password" name="password1" size="30"></p>
    <p class="style3"><label for="password2">Re-enter Password:</label>
    <input type="password" title="Please re-enter password" name="password2" size="30"></p>
    <p style="stext-align:left"><label for="submit">&nbsp</label>
    <input type="submit" value="Change" class="submit-button"/></p>
</form>
<font face='Verdana' size='2' color=red>{$msg}</font>
<font face='Verdana' size='2' color=red>{$msg1}</font>
<font face='Verdana' size='2' color=red>{$msg2}</font>
<font face='Verdana' size='2' color=red>{$empty_fields_message}</font>
<font face='Verdana' size='2' color=red>{$message}</font>
<div class="clearer"> </div>
</div>
<!--Left Column Inner End-->
</div>
<!--Left Column End-->
<!--Right Column Start-->
<div id="sidebar-wrapper">
<!--Right Column Inner Start-->
<div id="sidebar-content" class="roundedcorner">
<!--Conent-->
<div class="clearer"> </div>
<div class="box roundedcorner">
{include file="memberbar.tpl"}
</div>
<div class="clearer"> </div>
<div class="box roundedcorner">
{include file="news.tpl"}
</div>
<div class="clearer"> </div>
<div class="box roundedcorner">
{include file="language.tpl"}
</div>
<div class="clearer"> </div>
<!--Right Column Content End-->
</div>
<!--Right Column Inner End-->
</div>
<!--Right Column End-->
<div class="clearer"> </div>
</div>
<!--Container End-->
{include file="footer.tpl"}
winracer
myfunnypets.com
helpmewithperl.com
coosavalleyclassifieds.com
brownlows.net
myphpforum.com

Offline winracer

  • Development Team
  • Pro Member
  • *******
  • Posts: 446
  • Karma: 3
    • View Profile
    • helpmewithperl.com
  • Script Version: 1.0+
Re: Let user change password
« Reply #1 on: March 13, 2010, 04:24:08 AM »
last create new file changepassword.php
and put this in it

Code: [Select]
<?


ob_start();
session_start();
if(!isset($_COOKIE["id"]))
{
     header("Location: login.php");
}
else
{

session_start();  // Start Session
include("header.php");
//for testing
//if(!isset($_COOKIE["user"])){
//echo "<center><font face='Verdana' size='2' color=red>Sorry, Please login and use this page </font></center>";
//exit;
//}

$userb = $_COOKIE["user"];
$password1 = $_POST['password1'];
$password2 = $_POST['password2'];
if (!isset($_POST['password1'])) {

}
elseif (empty($password1) || empty($password2))  {
    $empty_fields_message = "<font face='Verdana' size='2' color=red>Please complete all the fields in the form.</font>";//Click <a class=\"two\" href=\"javascript:history.go(-1)\">here</a> to go back";

}
else {


$db_password1=md5(mysql_real_escape_string($password1));
//Setting flags for checking
$status = "OK";
$msg="";
if ( strlen($password1) < 3 or strlen($password1) > 10 ){
$msg1= "Password must be more than 3 characters in length and maximum 10 characters in length<BR>";
$status= "NOTOK";}     
if (strcmp( $password1,$password2 ) !=0){
$msg2="Both passwords do not match<BR>";
$status= "NOTOK";}     
if($status<>"OK"){
$msg = "<font face='Verdana' size='2' color=red>$msg</font><br>";//<center><input type='button' value='Retry' onClick='history.go(-1)'></center>";
}else{ // if all validations are passed.
if(mysql_query("UPDATE pp_user SET pass='$db_password1' where user= '$userb'"));
{
$message = "<font face='Verdana' size='2' ><center>Thanks ". $userb ."<br> Your password changed successfully. <br> Please keep changing your password for better security<br></font>Your New Password is ". $password1."</center>";
}

}
}
$smarty->assign('message', $message);
$smarty->assign('empty_fields_message', $empty_fields_message);
$smarty->assign('msg', $msg);
$smarty->assign('msg1', $msg1);
$smarty->assign('msg2', $msg2);
$smarty->display('changepassword.tpl');

}

?>

winracer
myfunnypets.com
helpmewithperl.com
coosavalleyclassifieds.com
brownlows.net
myphpforum.com

Offline winracer

  • Development Team
  • Pro Member
  • *******
  • Posts: 446
  • Karma: 3
    • View Profile
    • helpmewithperl.com
  • Script Version: 1.0+
Re: Let user change password
« Reply #2 on: March 13, 2010, 04:24:53 AM »
please let me now if you see a bug I tested and did not see any
thanks
winracer
myfunnypets.com
helpmewithperl.com
coosavalleyclassifieds.com
brownlows.net
myphpforum.com