+ Start a Discussion
sfdotcomsfdotcom 

how to generate a paasword which is same as username in visualforce?

I want the Visualforce code for creating login form & whenever user create the account, form should automatically  generating new password same as username & password should be sent in email.?

plz give me code for above task. i need it.

thanks in advance..............
Pramod_SFDCPramod_SFDC
Hi,

You can create a custom login page for a site, but I very much doubt you'll be able to do this for standard salesforce. However, Below is the sample VF page where you can insert the details and save it. Kindly change the field values according to your requirement

============

<apex:page controller="testController" showHeader="false" sidebar="false" tabStyle="account">
<apex:form >
  <apex:pageBlock >
   <apex:pageBlockSection >
    <apex:inputfield value="{!reg.First_Name__c}"/><br></br>
    <apex:inputfield value="{!reg.Last_Name__c}"/><br></br>
    <apex:inputfield value="{!reg.Username__c}"/><br></br>
   
   </apex:pageBlockSection>
    <apex:commandButton value="Save" action="{!save}"/> 
  </apex:pageBlock>
</apex:form>
</apex:page>


===================

public class testController
{


public greenworld__c reg{get;set;}
public greenworld__c  temp {get;set;}


public testController()
{
reg=new greenworld__c();
}
Public pageReference Save()
{
// here copy the user name to a password field
reg.password__c=reg.username;
insert reg

=====================


I believe, it help you. Have a Great Day !!



Thanks
Pramod_SFDCPramod_SFDC
Hi,

Below is a trigger, which i forgot post, my bad. Which will send an Email with user name and password.PLEASE CHNAGE IT ACCORDING TO YOUR REQUIREMENT

===============

trigger greenworld on register__c (after insert)
{

// A list to store the new trigger value

list<register__c> green= new list <register__c>();
green=trigger.new;

//subject of the E-mail

string subject='Registration Successfull';

// Body of the E-mail
string body= 'Hello,<br/><br/>You Have Successfully Registered with our site.<br/><br/>Stay connected with our site to get updates<br/><br/>Regards<br/><br/> Green World';

// Array of ype string to store toaddress
String[] toaddresses = new String[]{};

// looping statement to store the to addrees through Trigger.new values
for(register__c g1:green)
{
toaddress.add(g1.email_id__c);
}

//SingleEmailMessage method
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

// SEM method to set to address
mail.setToAddresses(toaddresses);

// SEM method to set subject
mail.setsubject(subject);

// SEM method to set body of E-mail >> Here you can include the field of Username and Password and send the mail

mail.setHtmlBody('Username  <b>'+green[0].First_Name__c+ <br/><br/> <b>Password : </b>'+green[0].password+ '<br/><br/> Thanks.. <br/><br/><b>Regards<br/> GREEN WORLD</b>');

// standard Send E-mail maethod
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });



THANKS
sfdotcomsfdotcom
Hi Pramod_SFDC,

Thanks for your help..

Plz  take sometime to solve the problem...
My Task:

I created an Object called 'User'.
Fields:
1. Standard Field - User Name,  Field Type- Text
2. Custom Field - Email,  Field Type - Email

--> Now create a Custom buton 'Register' for User Object.

Once we click 'Register' after inserting User Name and Email,  an s email should be sent to the specified email with new generated password.

Object: Detail page:

Standard & Custom field


Tab: User Interface

User-added image

Remove the Save, Save & New, Cancel buttons.
and create Register, Signin buttons.


Create VF page & Custom Controllers for above task with given fields
Plz reply

Thanks in advance..