Page 1 of 1

Forgot Your Username with security question and answer j1.5

Posted: Fri Oct 09, 2009 6:35 am
by arjuninfo
Forgot Your Username with security question and answer with joomla 1.5

Forgot Your Username in joomla 1.5

Posted: Fri Oct 09, 2009 6:38 am
by arjuninfo
Insert this code in

components\com_user\views\remind\tmpl\default.php


<div class="content_title"><span class="blue">Forgot </span><span class="dark_blue">Your Username</span></div>
<div style="margin-left:40px; margin-top:20px; width:500px;">
<form action="index.php?option=com_user&task=remindusername&Itemid=213" method="post" name="josForm" id="josForm" class="form-validate" style="padding:0; margin:0;" onSubmit="return ValidateForm()">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="contentpane">
<tr>
<td colspan="2">
<font color="#0099FF">
<?php
/*if(isset($this->username))
{
echo "YOUR USERNAME : ".$this->username;
}*/

echo $_GET['msg'];
?>

</font> </td>
</tr>
<tr>
<td style="padding-top:30px" width="140">
<div align="left">
<label id="" for="security" class="page-content-2">
<span class="astriek">* </span>
<?php echo JText::_('Security Question'); ?></label>
</div> </td>
<td style="padding-top:30px">
<div align="left">
<?php echo $this->lists['security'];?> </div> </td>
</tr>
<tr>
<td style="padding-top:30px">
<label id="" for="answer" class="page-content-2">
<span class="astriek">* </span><?php echo JText::_( 'Your Answer' ); ?> </label> </td>
<td style="padding-top:30px">
<input title="Please Enter Your Answer" class="inputbox req val textbox_bg" type="text" id="answer" name="answer" value="<?php echo JRequest::getVar('answer');?>" maxlength="100" style="width:275px; "/> </td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><span class="astriek">* </span>Email Id </td>
<td><input id="email" name="email" type="text" class="required validate-email textbox_bg" style="width:275px; " maxlength="100" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="Submit" style="margin-left:230px;" value="<?php echo JText::_('Submit'); ?>" /> </td>
</tr>
</table>

<?php echo JHTML::_( 'form.token' ); ?>
</form>
</div>

Custom fields in joomla 1.5 Forgot your username

Posted: Fri Oct 09, 2009 6:42 am
by arjuninfo
then goto

components\com_user\controller.php


function remindusername()
{
$db =& JFactory::getDBO();

// Check for request forgeries
JRequest::checkToken() or jexit( 'Invalid Token' );

// Get the input
$email = JRequest::getVar('email', null, 'post', 'string');

$security = JRequest::getVar('security', null, 'post', 'string');

$answer =JRequest::getVar('answer', null, 'post', 'string');


// Get the model
$model = &$this->getModel('Remind');

$query = "SELECT username FROM jos_users WHERE email='".$email."' AND security='".$security."' AND answer='".$answer."'";

$db->setQuery($query);
$member_info = $db->loadObjectList();


/* print "<pre>";
print_r($member_info);


if(!empty($member_info)){
print 'if';
}
else
{
print 'else';
}exit();*/

if(($model->remindUsername($email) === false) && (empty($member_info)))
{

$message = JText::sprintf('USERNAME_REMINDER_FAILED', $model->getError());
$this->setRedirect('index.php?option=com_user&view=remind&Itemid=212&msg=Please enter a correct answer', $message);
return false;


}

$message = JText::sprintf('USERNAME_REMINDER_SUCCESS', $email);
$this->setRedirect('index.php?option=com_user&view=remind&Itemid=212&msg=Please check your mail for username details', $message);


}



function _sendMail(&$user, $password)

Re: Forgot Your Username with security question and answer j1.5

Posted: Fri Oct 09, 2009 10:32 am
by ooffick
Mod Note: Moved to Core Hacks Forum

Re: Forgot Your Username with security question and answer j

Posted: Mon Mar 14, 2011 10:56 am
by paresh12
Hello Arjun

Thanks for nice post.

Can you please tell me how can i add question and database fields?

Currently security question form display in forget username page but not comes on registration page. :'(

Can you please provide full code?

Thanks