You need to sign in to do that
Don't have an account?

Can you please Solve this Problem?
Hi all,
I am creating one Custom object(Members__C) , Fields are UserName, Password, Phone No, Email ID.
Records:-
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">
<style>
body{
background-color:#f1ebdd;
}
.bold{
font-weight:bold;
color:#FFF;
font-size:20px;
}
</style>
<script type="text/javascript">
function f1(){
var txt1=document.getElementById('{!$Component.frm1.txtname}').value;
if(txt1==null||txt1==""){
alert("Please enter Username");
return false;
}
var pwd=document.getElementById('{!$Component.frm1.txtpwd}').value;
if(pwd==null||pwd==""){
alert("Please enter Password");
return false;
}
}
</script>
</apex:form>
<apex:form id="frm1" >
<table border="2" width="100%" height="100px;">
<tr>
<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>
<br/>
User Name:
<br/>
<apex:inputText id="txtname" value="{!uname}" />
<br/>
Password :<br/><apex:inputSecret value="{!pwd}" id="txtpwd" />
<br/>
<apex:commandButton value="Sign In" onclick="f1();" action="{!submit}"/><br/>
</div>
</td>
</tr>
</table>
</apex:form>
</apex:page>
Class:-
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){
p1.setRedirect(true);
}
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){
p1.setRedirect(true);
}
return null;
}
}