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
Arpita NayakArpita Nayak 

Login page

Hi ,
I am creating a login page in visualforce page .Can any one please suggest some code??
Abhishek Vishwakarma 5Abhishek Vishwakarma 5

Hi Arpita,

Here is the thing what u need, This is a Login Page combination of CSS. Hope this will resolve your issue.

Visualforce Page
 

<apex:page sidebar="false" controller="LoginPage_CTR" showheader="false" standardStylesheets="false">
<apex:form >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>

/* Basics */
html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: "Helvetica Neue", Helvetica, sans-serif;
    color: #444;
    -webkit-font-smoothing: antialiased;
    background: #f0f0f0;
}

  p.remember_me {
    float: left;
    line-height: 8px;

    label {
      font-size: 8px;
      color: #777;
      cursor: pointer;
    }

    input {
      position: relative;
      bottom: 1px;
      margin-right: 4px;
 
      vertical-align: middle;
    }
  }
#container {
    position: fixed;
    width: 366px;
    height: 286px;
    top: 50%;
    left: 50%;
    margin-top: -140px;
    margin-left: -170px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #ccc;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .1);
    
}
form {
    margin: 0 auto;
    margin-top: 20px;
}
label {
    color: #555;
    display: inline-block;
    margin-left: 18px;
    padding-top: 10px;
    font-size: 14px;
}
p a {
    font-size: 11px;
    color: #aaa;
    float: right;
    margin-top: -13px;
    margin-right: 20px;
 -webkit-transition: all .4s ease;
    -moz-transition: all .4s ease;
    transition: all .4s ease;
}
p a:hover {
    color: #555;
}
input {
    font-family: "Helvetica Neue", Helvetica, sans-serif;
    font-size: 12px;
    outline: none;
}
input[type=text],
input[type=password] {
    color: #777;
    padding-left: 10px;
    margin: 10px;
    margin-top: 12px;
    margin-left: 18px;
    width: 290px;
    height: 28px;
    border: 1px solid #c7d0d2;
    border-radius: 2px;
    box-shadow: inset 0 1.5px 3px rgba(190, 190, 190, .4), 0 0 0 5px #f5f7f8;
-webkit-transition: all .4s ease;
    -moz-transition: all .4s ease;
    transition: all .4s ease;
    }
input[type=text]:hover,
input[type=password]:hover {
    border: 1px solid #b6bfc0;
    box-shadow: inset 0 1.5px 3px rgba(190, 190, 190, .7), 0 0 0 5px #f5f7f8;
}
input[type=text]:focus,
input[type=password]:focus {
    border: 1px solid #a8c9e4;
    box-shadow: inset 0 1.5px 3px rgba(190, 190, 190, .4), 0 0 0 5px #e6f2f9;
}
#lower {
    height: 81px;
    margin-top: 24px;
    background: #ecf2f5;
    width: 100%;
    
    border-radius:6px;
    box-shadow: inset 0 1px 1px #fff;
    border-top: 1px solid #ccc;
    border-bottom-right-radius: 3px;
    border-bottom-left-radius: 3px;
}
input[type=checkbox] {
    margin-left: -12px;
    margin-top: 11px;
}
.check {
    margin-left: 3px;
    font-size: 11px;
    color: #444;
    text-shadow: 0 1px 0 #fff;
}
input[type=submit] {
    float: right;
    margin-right: 20px;
    margin-top: 8px;
    width: 80px;
    height: 30px;
    font-size: 14px;
    font-weight: bold;
    color: #fff;
    background-color: #acd6ef; /*IE fallback*/
    background-image: -webkit-gradient(linear, left top, left bottom, from(#acd6ef), to(#6ec2e8));
    background-image: -moz-linear-gradient(top left 90deg, #acd6ef 0%, #6ec2e8 100%);
    background-image: linear-gradient(top left 90deg, #acd6ef 0%, #6ec2e8 100%);
    border-radius: 6px;
    border: 1px solid #66add6;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .5);
    cursor: pointer;
}
input[type=submit]:hover {
    background-image: -webkit-gradient(linear, left top, left bottom, from(#b6e2ff), to(#6ec2e8));
    background-image: -moz-linear-gradient(top left 90deg, #b6e2ff 0%, #6ec2e8 100%);
    background-image: linear-gradient(top left 90deg, #b6e2ff 0%, #6ec2e8 100%);
}
input[type=submit]:active {
    background-image: -webkit-gradient(linear, left top, left bottom, from(#6ec2e8), to(#b6e2ff));
    background-image: -moz-linear-gradient(top left 90deg, #6ec2e8 0%, #b6e2ff 100%);
    background-image: linear-gradient(top left 90deg, #6ec2e8 0%, #b6e2ff 100%);
}
</style>
 
</head>
 
    <!-- Begin Page Content -->
    <apex:pageMessages id="errorMsg"/>
    <div id="container">
        <form>
           <label for="username">Username:</label>
            <apex:inputtext value="{!username}" html-placeholder="Username"/>
            <label for="password">Password:</label>
            <apex:inputsecret value="{!password}" html-placeholder="Password"/>
             <p class="remember_me">
              <label>
                    <input type="checkbox" name="remember_me" id="remember_me"/>
                    Remember me on this computer
                      </label>
                </p>
            <div id="lower">            
             
                <apex:commandbutton style="height: 42px;
    width: 123px;
    border-radius: 47px;
    background: #3AC9F2;" action="{!doLogin}" rerender="errorMsg"  value="Login"/>
              
             </div><!--/ lower-->
              
              <apex:commandLink style="margin-left:112px!important" value="Forgot Password" />
        </form>
    </div><!--/ container-->
    <!-- End Page Content -->
</apex:form>
</apex:page>
Apex Class :
 
public class LoginPage_CTR{
 
public String username{get; set;}
public String password {get; set;}
private String msg;  
private transient ApexPages.Message currentMsg;
 
public pageReference registration()
{  
    PageReference pg = new PageReference('/apex/Registration');
    pg.setRedirect(True);
    return pg;
}
public pageReference doLogin()
{  
    Contact c = new Contact();
    PageReference pg;
    List<contact> cnt = [Select id,User_Name__c,Password__c from contact where User_Name__c =: username limit 1];
       system.debug(cnt.size());
       if(cnt.size() == 0)
       {
             
             msg = 'Invalid Customer Id(User Name)';
             currentMsg = new ApexPages.Message(ApexPages.severity.INFO, msg);
             ApexPages.addMessage(currentMsg);   
       }
        else
        {
        if(string.ValueOf(cnt[0].Password__c) != password)
        {
            msg = 'Invalid Password';
            currentMsg = new ApexPages.Message(ApexPages.severity.INFO, msg);
            ApexPages.addMessage(currentMsg);        
        }
        else
        {
            pg = new PageReference('/apex/CasesRelated');
            pg.setRedirect(True);
            Map<String,String> p = pg.getParameters();
            p.put('user',username);
            p.put('pass',password);
            return pg;
        }
        }     
    return pg;
}

}
Please select the best answer so it should be helpful to others.

Thanks,
Abhishek