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
RavitejaRaviteja 

i want creat loginpage

i created one object to maintain the username&passwords of users.i wrote some code it showing error...


vf
-----
<apex:page Controller="Logincls" sidebar="false">
<apex:form >
  <apex:pageBlock title="GMAIL ACCOUNT" >
  <apex:pageBlockSection title="ENTER USERNAME&PASSWORD">
  <apex:inputtext label="USERNAME" Value="{UserID}"/>
  <apex:outputText ></apex:outputText>
  <apex:inputtext label="PASSWORD" Value="{Password}"/>
  </apex:pageBlockSection>
  <apex:pageblocksection >
  <apex:commandButton value="LOGIN" action="{!login}"/>
  </apex:pageblocksection>
  </apex:pageBlock>
  </apex:form>
</apex:page>

apex
-------
public class logincls
{
public string pass;
public string userid{get;set;}
public string password{get;set;}
{
pass=[select password__c from login__c where user_id__c=:userid];
}
public pagereference login
{
if(password=pass)
pagereference hello = new pagereference('apex/helloworld');
hello.setredirect(true);
return hello;
}
}

THANKS IN ADVANCE...
SamuelDeRyckeSamuelDeRycke

It helps if you specify a specific question, or at least show us the error you are receiving.

 

<apex:page Controller="Logincls" sidebar="false">
    <apex:form>
        <apex:pageBlock title="GMAIL ACCOUNT">
            <apex:pageBlockSection title="ENTER USERNAME&PASSWORD">
                <apex:inputtext label="USERNAME" Value="{! UserID}" />
                <apex:outputText></apex:outputText>
                <apex:inputtext label="PASSWORD" Value="{! Password}"/>
</apex:pageBlockSection> <apex:pageblocksection> <apex:commandButton value="LOGIN" action="{!login}" /></apex:pageblocksection> </apex:pageBlock> </apex:form> </apex:page>

apex:

 

public class logincls {
   // public string pass; //why have this as a class variable ?
    public string userid {get;set;}
    public string password {get;set;} 
public pagereference login {
string pass = [select password__c from login__c where user_id__c = : userid]; //may want to encrypt passwords, or actually not store them at all, specially if you deal with other services like gmail, there are better authentication mechanisms for this.
if (password == pass){
pagereference hello = new pagereference('apex/helloworld');
hello.setredirect(true);
return hello;
} else{
return null;
}
}

 Only typed it here, so may have typos or may have looked over somethings, but this should get you in the right direction.