<code><?php
/**
*Template Name: Forget Password
The template for displaying all pages.
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site will use a
* different template.
*
* @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/
get_header(); ?>
<?php get_sidebar(); ?>
<script type = 'text/javascript'>
function join_team()
{
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if(reg.test(document.getElementById("email_user").value) == false)
{
alert("Please enter a valid email");
document.getElementById('email_user').focus();
return false;
}
}
</script>
<?php
function createRandomPassword() {
$chars = "abcdefghijkmnopqrstuvwxyz023456789";
srand((double)microtime()*1000000);
$i = 0;
$pass = '' ;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($chars, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
// Usage
if(isset($_REQUEST['forgetpwd']) )
{
$password = createRandomPassword();
$mail_address = $_REQUEST[email_user];
$query = "select * from wp_users where user_email='".$mail_address."'";
//echo $query;
$rs = mysql_query($query);
$row = mysql_fetch_assoc($rs);
$newpwd = md5($password );
if($row['user_email']==$mail_address)
{
$query1 = "update wp_users set user_pass='".$newpwd."' where user_email ='".$mail_address."'";
///echo $query1;
$row1 = mysql_query($query1);
$to = $mail_address; //brokeremail
$from = "Info@ledworld.com"; //visitoremail
$subject ="Forgot Password";
$message = "";
$message .= "Dear ".$row['user_login'].",<br><br>Your Login information along with password is as mentioned below :<br><br>";
$message .= "Username : ".$row['user_login']."<br>";
$message .= "Password : ".$password."<br>";
//$message .= "Message : ".$_POST['txtmsg']."<br>";
//$message .="File : ".$_POST['upfile']."<br>";
$message .= "<br><br><br>Thank You ,<br> Support Team";
$message;
$headers ="MIME-Version: 1.0" . "\r\n";
$headers .="Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .="From: $from" . "\r\n";
$abc=@mail($to,$subject,$message,$headers);
if($abc)
{
echo " <script>alert('mail send'); window.location='/wordpress/ledworld/login/'</script>";
}
else
{
echo "<script>alert('Mail send Succesfully');</script>";
echo "<div class = 'email_msg' >".$msg = "Email Send Sucessfully". "</div>";
//echo "<script>window.location='?page_id=121&action=forget'</script>";
echo "<script>window.location='/wordpress/ledworld/lost-password/'</script>";
}
}
else
{
$error_msg = "Email Address is not exists in our record";
}
}
?>
<div class="c_right">
<div class="c_heading">Lost Password</div>
<div class="login">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form method = "post" action = "" onsubmit = 'return join_team();'/>
<tr>
<td colspan ="3" align = "center">
<?php if($error_msg!="")
{?>
<span style = "color:red;adding-left: 49px;"><?php echo $error_msg; ?></span>
<?php
}
?>
</td>
</tr>
<tr>
<td width="39%" align="right">Email:</td>
<td width="1%" height="35"> </td>
<td width="60%">
<input name="email_user" type="text" id = "email_user" class="form_fild" /> </td>
</tr>
<tr>
<td align="right"> </td>
<td height=""> </td>
<td valign="bottom"><input type = "hidden" name = "forgetpwd"/><input type = "image" src="<?php bloginfo('template_url');?>/images/getpassword.png" alt="" width="141" height="26" /></td>
</tr>
</table>
</form>
</div>
</div>
<?php get_footer(); ?></code>
/**
*Template Name: Forget Password
The template for displaying all pages.
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site will use a
* different template.
*
* @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/
get_header(); ?>
<?php get_sidebar(); ?>
<script type = 'text/javascript'>
function join_team()
{
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if(reg.test(document.getElementById("email_user").value) == false)
{
alert("Please enter a valid email");
document.getElementById('email_user').focus();
return false;
}
}
</script>
<?php
function createRandomPassword() {
$chars = "abcdefghijkmnopqrstuvwxyz023456789";
srand((double)microtime()*1000000);
$i = 0;
$pass = '' ;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($chars, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
// Usage
if(isset($_REQUEST['forgetpwd']) )
{
$password = createRandomPassword();
$mail_address = $_REQUEST[email_user];
$query = "select * from wp_users where user_email='".$mail_address."'";
//echo $query;
$rs = mysql_query($query);
$row = mysql_fetch_assoc($rs);
$newpwd = md5($password );
if($row['user_email']==$mail_address)
{
$query1 = "update wp_users set user_pass='".$newpwd."' where user_email ='".$mail_address."'";
///echo $query1;
$row1 = mysql_query($query1);
$to = $mail_address; //brokeremail
$from = "Info@ledworld.com"; //visitoremail
$subject ="Forgot Password";
$message = "";
$message .= "Dear ".$row['user_login'].",<br><br>Your Login information along with password is as mentioned below :<br><br>";
$message .= "Username : ".$row['user_login']."<br>";
$message .= "Password : ".$password."<br>";
//$message .= "Message : ".$_POST['txtmsg']."<br>";
//$message .="File : ".$_POST['upfile']."<br>";
$message .= "<br><br><br>Thank You ,<br> Support Team";
$message;
$headers ="MIME-Version: 1.0" . "\r\n";
$headers .="Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .="From: $from" . "\r\n";
$abc=@mail($to,$subject,$message,$headers);
if($abc)
{
echo " <script>alert('mail send'); window.location='/wordpress/ledworld/login/'</script>";
}
else
{
echo "<script>alert('Mail send Succesfully');</script>";
echo "<div class = 'email_msg' >".$msg = "Email Send Sucessfully". "</div>";
//echo "<script>window.location='?page_id=121&action=forget'</script>";
echo "<script>window.location='/wordpress/ledworld/lost-password/'</script>";
}
}
else
{
$error_msg = "Email Address is not exists in our record";
}
}
?>
<div class="c_right">
<div class="c_heading">Lost Password</div>
<div class="login">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form method = "post" action = "" onsubmit = 'return join_team();'/>
<tr>
<td colspan ="3" align = "center">
<?php if($error_msg!="")
{?>
<span style = "color:red;adding-left: 49px;"><?php echo $error_msg; ?></span>
<?php
}
?>
</td>
</tr>
<tr>
<td width="39%" align="right">Email:</td>
<td width="1%" height="35"> </td>
<td width="60%">
<input name="email_user" type="text" id = "email_user" class="form_fild" /> </td>
</tr>
<tr>
<td align="right"> </td>
<td height=""> </td>
<td valign="bottom"><input type = "hidden" name = "forgetpwd"/><input type = "image" src="<?php bloginfo('template_url');?>/images/getpassword.png" alt="" width="141" height="26" /></td>
</tr>
</table>
</form>
</div>
</div>
<?php get_footer(); ?></code>
No comments:
Post a Comment