function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Salesforce Developer IndiaSalesforce Developer India 

Can you please Solve this Problem?

Hi all,


I am creating one Custom object(Members__C) , Fields are UserName, Password, Phone No, Email ID.


1) userName=user1 and Password=pwd1

2) userName=user2 and password=pwd2


i created one vf Page( Login page), and another page Is Personal Information Page.


Whenever i am login to Username and Password is correct it will navigate to Pesonal Information Page.


But i am passing User Name is "user1" and password is "pwd2". But does not show any Error Messages.  It will also navigate to Personal Information page.


VF Login page:-



<apex:page controller="svtmemberlogin" title="Sri Rama Seva Trust Admin Page" sidebar="false" showHeader="false" standardStylesheets="false">
<script type="text/javascript">
function f1(){
var txt1=document.getElementById('{!$Component.frm1.txtname}').value;
alert("Please enter Username");
return false;

var pwd=document.getElementById('{!$Component.frm1.txtpwd}').value;
alert("Please enter Password");
return false;
<apex:form id="frm1" >
<table border="2" width="100%" height="100px;">
<td width="35%"></td>
<td style="background:#724486;">
<div id="d1" Valign="Top">
<p style="margin-left:20px; margin-top:5px;">
<apex:outputText styleClass="bold" value="Already a Member?Login"> </apex:outputText>
User Name:
<apex:inputText id="txtname" value="{!uname}" />
Password :<br/><apex:inputSecret value="{!pwd}" id="txtpwd" />
<apex:commandButton value="Sign In" onclick="f1();" action="{!submit}"/><br/>





public class svtmemberlogin {
public String uname{get;set;}
public String pwd{get;set;}
SVT_Members__c s1=new SVT_Members__c();

public PageReference Submit(){
PageReference p1=new PageReference('/apex/SVTMemberPersonal_Information');
PageReference p2=new PageReference('/apex/SVTMember');
if(s1.userNAme==uname && s1.Password__c==pwd){


return p1;



Can u please send the vallid code.....


Thanks for u help.........


I see two issues:


1. s1 uname and pwd will always be null as you are setting s1 = New SVT_Members__c

2. You are always returning a pagereference so the new page will be displayed. The setRedirect just determins if the view state will be maintained or not. Change it to:


if(s1.userNAme==uname && s1.Password__c==pwd){


return null;