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
Hakim Upadhyay 45Hakim Upadhyay 45 

Parameter is not passing from one visualforce page to another visualforce page

I am new in the Salesforce coding. I have two pages. On one page I am filling the data and saving it. After click on Save button, I want to see the exact same data which I filled on last page. This is my code.
When I click on Save button first time, it stay on the same page. When I click on Save button again, it throws a message "The page you submitted was invalid for your session. Please refresh your page and try again

--------------------------------------FIRST VF PAGE-----------------------------------------
<apex:pageBlockSection title="Please fill the visitor information " collapsible="true">
  <apex:inputField value="{!visitor.Name}"/>  <br/>     
    <apex:pageMessages id="showmessage">
      </apex:pageMessages><br/>                     
        <apex:inputField value="{!visitor.CountryName__c}"/><br/>             
        <apex:inputField value="{!visitor.Passport_Number__c}"/><br/>           
        <apex:inputField value="{!visitor.Covid_19_Symtomp__c}"/><br/>
        <apex:inputField value="{!visitor.SendToQuarantineCenter__c}"/> <br/>           
        <apex:inputField value="{!visitor.CanVisitorGoToHome__c}"/><br/>
        <apex:inputField value="{!visitor.Quarantine_Cetner__c}"/><br/>
        <apex:inputField value="{!visitor.PatientEntryDate__c}"/><br/>
        <apex:inputField value="{!visitor.Patient_Exit_Date__c}"/><br/>
        </apex:pageBlockSection>        
                <apex:pageBlockButtons location="top">
        <apex:commandButton action="{!saveV }" value="Save" reRender="true" />        
        </apex:pageBlockButtons>         
        </apex:pageBlock>
    </apex:form>    
--------------------------------Apex Code-----------------------------------
public class VisitorRegistration {   
       public Visitor__c visitor{get;set;}       
    public VisitorRegistration()
    {
        visitor= new Visitor__c();               
    }        
   public void getVisitorID()
{
Id id = apexpages.currentpage().getparameters().get('Id');
}    
 public PageReference saveV()
    {
        If(visitor.Name==null || visitor.Name=='')
        {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter value'));
        }   
INSERT visitor;     
pagereference pr = new pagereference('/apex/VisitorRegistrationViewPage?id='+Visitor__c.id);  
        pr.setRedirect(false);
return pr;
    }
}

-------------------Second VF PAGE Where I want to See the Data
<apex:page controller="VisitorRegistration" showHeader="false" sidebar="false">
    <apex:form >
        <apex:pageBlock title="Visitor Detail Page">
        
        <apex:pageBlockSection title="Visitor Information " collapsible="true">
             <apex:outputField value="{!visitor.Name}"/>  <br/>
            <apex:outputField value="{!visitor.CountryName__c}"/><br/>             
            <apex:outputField value="{!visitor.Passport_Number__c}"/><br/>           
            <apex:outputField value="{!visitor.Covid_19_Symtomp__c}"/><br/>
               <apex:outputField value="{!visitor.SendToQuarantineCenter__c}"/> <br/>           
            <apex:outputField value="{!visitor.CanVisitorGoToHome__c}"/><br/>
            <apex:outputField value="{!visitor.Quarantine_Cetner__c}"/><br/>
            <apex:outputField value="{!visitor.PatientEntryDate__c}"/><br/>
            <apex:outputField value="{!visitor.Patient_Exit_Date__c}"/><br/>
            </apex:pageBlockSection>
        </apex:pageBlock>    
         </apex:form>
</apex:page>


Please let me know , what is the mistake here. 
 
ANUTEJANUTEJ (Salesforce Developers) 
Hi Hakim,

Can you mention if the values you are giving if they are being saved as a new record or not?

Regards,
Anutej