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
Michael Hedrick 2Michael Hedrick 2 

Populate Visualforce Page from user input

Hello everyone,
I have a visualforce page thatreside on a public website.
The user enters information on 2 fields.  Then completes a  captcha. 
The user then clicks a button on the VF page.
Assuming the Captcha is succesful I need to go back to the Salesforce org to return Acount data based on the 2 field and populate fields on the same VF page.  I am familiar passing information from Salesforce to a VF page but I am not sure how to retrieve the data from Salesforce based on user input on a VF page.  Any suggestions would be greatly appreciated.

You just give   permission   your Object and vf page  Read , Write   in  Site Public Page Setting
Michael Hedrick 2Michael Hedrick 2
Thank you for the reply.
I should have been more specific.
here is my Visual Force page
<apex:page controller="Captcha" cache="false">
<apex:pageBlock title="Captcha Verification">
<apex:form >
<apex:pageBlockSection columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel for="inputStore" value="Store Number"/>
<apex:inputText value="{!myStore}" id="inputStore"/>
<apex:pageBlockSectionItem >
<apex:outputLabel for="inputpassword" value="Password"/>
<apex:inputText value="{!myPassword}" id="inputpassword"/>

<apex:pageBlockSectionItem rendered="{! NOT(verified)}">

<script type='text/javascript' src='{!publicKey}'>
<iframe src='{!publicKey}' height='300' width='500' frameborder='0'>
<textarea name='recaptcha_challenge_field' rows='3' cols='40'></textarea>
<input type='hidden' name='recaptcha_response_field' value='manual_challenge'/>

<apex:pageBlockSectionItem >
<apex:commandButton action="{!verify}" value="Check If I am not a robot" rendered="{! NOT(verified)}"/>

<apex:pageBlockSectionItem rendered="{!verified}">
Have Salesforce Address information display here 

Here is the class
public class  Captcha
    public boolean checkCurrentValue{get;set;}
    public String challenge{get;set;}
    public String response{get;set;}
    public String publicKey {get;set;}
    private static String privateKey = '6Ld0wgkTAAAAALlZg3d1iZBxEfTkK2Qy_vZ4SCFP';
    private static String baseUrl = '';
    public String myName { get; set; }
    public String myEmail { get; set; }
    public String myStore { get; set; }
    public String mypassword { get; set; }
    public Boolean verified { get; private set; }
    public Captcha()
        publicKey = '6Ld0wgkTAAAAAGkcvz8yxeZUSVpWQmCdxOkw9MIH';

        this.verified = false;
        challenge = ApexPages.currentPage().getParameters().get('recaptcha_challenge_field');
        response =  ApexPages.currentPage().getParameters().get('recaptcha_response_field');
    public PageReference verify()
        System.debug('reCAPTCHA verification attempt');
        // On first page load, form is empty, so no request to make yet
        if ( challenge == null || response == null )
            System.debug('reCAPTCHA verification attempt with empty form');
            return null;
        HttpResponse r = makeRequest(baseUrl,'privatekey=' + privateKey + '&remoteip='  + remoteHost + '&challenge=' + challenge + '&response='  + response);
        if ( r!= null )
            this.verified = (r.getBody().startsWithIgnoreCase('true'));
           How do I return the Salesforce Account address fields based on the Store Number and password that was entered by the user on the VF page.
           // Account act= getAddress();
            return null;
            // stay on page to re-try reCAPTCHA
            return null;
    public PageReference reset()
        return null;
    /* Helper methods */
    private static HttpResponse makeRequest(string url, string body) 
        HttpResponse response = null;
        HttpRequest req = new HttpRequest();  
        req.setBody (body);
            Http http = new Http();
            response = http.send(req);
            System.debug('reCAPTCHA response: ' + response);
            System.debug('reCAPTCHA body: ' + response.getBody());
        catch(System.Exception e)
            System.debug('ERROR: ' + e);
        return response;
    private String remoteHost
        get {
            String ret = '';
            // also could use x-original-remote-host
            Map<String, String> hdrs = ApexPages.currentPage().getHeaders();
            if (hdrs.get('x-original-remote-addr')!= null)
                ret =  hdrs.get('x-original-remote-addr');
            else if (hdrs.get('X-Salesforce-SIP')!= null)
                ret =  hdrs.get('X-Salesforce-SIP');
            return ret;

Just trying to figure out how to get the account information from salesforce to display on the VF page based on thr users input.