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
Chinmoy DebnathChinmoy Debnath 

After Logging in Getting Username through URL

Im creating a registration system, I want to get the username of user after logging in, through URL so that I can do SOQL queries.
Eg: Anyone named rick logged in
      I want the next page to be "Hi Rick"
      for this i need the username to get the details through SOQL
Chris Gary CloudPerformerChris Gary CloudPerformer
Why can you not use the $User global variable in order to get this information?  for example - once the user logs in through Salesforce, simply using the 'Hi {!$User.Firstname}' token?
Chinmoy DebnathChinmoy Debnath
my API Name is : Registration__c
and other fields are Email__c and Password__c

my login page code is:

<apex:page showHeader="false" sidebar="false" controller="login">
<h1>Login</h1>
<apex:form >
Email<apex:inputText value="{!email}"/>
Password<apex:inputSecret value="{!password}"/>
<apex:commandButton value="Submit" action="{!login}"/>
</apex:form>
</apex:page>

public class login
{
    public String email{set;get;}
    public String password{set;get;}
    public Registration__c fet=null;
    
    pageReference obj;
    public pageReference login(){
        try{
            fet=[SELECT name from Registration__c where Email__c=:email and Password__c=:password];
           }
           catch(Exception e){}
           if(fet!=null){
               obj=new pageReference('https://ap2.salesforce.com/apex/Index');
               obj.setRedirect(true);
           }
           else{
               obj=new pageReference('/apex/Login?success=user not valid');
               obj.setRedirect(true);
           }
           return obj;
    }
}

****now i want to get the username and his details in the index page. So, HOW???******