Sample Code:
Visualforce page1:
<apex:page controller="Sample">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Next Page" onclick="show();"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex class:
public class Sample {
public Sample() {
}
public PageReference next() {
return Page.Sample1;
}
}
Visualforce page2:
<apex:page >
This is the second page.
</apex:page>
Output:

