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
Alfredo Ornelas 4Alfredo Ornelas 4 

Force.com sites web form ERROR please help!

I created a VF page for a web form with sites. If the prospect goes to our website and enter all the required information on the form and click submit the "Authorization Required" Error appear on screen.
When I preview my VF page, enter all the required information and click submit, my Thank You page appears working properly. What I'm missing?

My Class and VF page below:
 
<apex:page standardController="Lead" extensions="myWeb2LeadExtension" title="Contact Us" showHeader="false" standardStylesheets="false">
  <apex:define name="body">
    <apex:pageBlock title="" mode="edit">
    
        <link href='http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300' rel='stylesheet' type='text/css'></link>
    
<style type="text/css">

    body { 
        width: 100%; 
        height: auto; 
        margin: 0px; 
        padding: 0px;
        background-color: #ebebeb; 
        }
    
    #HEheader {
        margin: auto;
        width: 100%;
        height: 43px;
        background-color: #000;
        }
        
    #centered {
        margin: auto;
        width: 1024px;
        height: auto;
        background-color: #ffffff;
        overflow-y: auto;
        }

    #HEhead {
        margin: auto;
        width: 999px;
        height: 31px;
        padding-top: 12px;
        padding-left: 25px;
        }

    #EPheader {
        margin: auto;
        width: 999px;
        height: 70px;
        padding-top: 12px;
        padding-left: 25px;
        }
    #pageTitle {
        padding-left: 25px;
        width: 875px;
        font-family:'Open Sans Condensed', sans-serif;
        font-size:30px;
        font-weight:bold;
        color: #00728f;
        }
     #pageDesc {
        margin: 10px 0px 0px 0px;
        padding-left: 25px;
        width: 860px;
        font-family:'Open Sans Condensed', sans-serif;
        font-size:24px;
        font-weight:Normal;
        color: #333;
        }
    #pageBody{
        float: left;
        margin: 0px 25px 50px 25px;
        width: 390px;
        font-family:'Open Sans Condensed', sans-serif;
        font-size:18px;
        font-weight:Normal;
        color: #000;
        }
    #picture {
        float: left;
        margin: 15px 10px 0px 10px;
        }
    #FormCon  {
        float: left;
        margin: 0px 0px 0px 25px;
        width: 275px;
        }
    #EPformHead {
        height: 60px;
        }
    #EPform {
        padding: 15px;
        width: 315px;
        background-color: #e4e4e4;
        font-family:Verdana, Geneva, sans-serif;
        font-size:12px;
        text-align:left;
        }

</style>

    
   

      <script type="text/javascript">
      window.onload=function() {
          var queryDict = {}
          var cid = '';
          location.search.substr(1).split("&").forEach(function(item) {queryDict[item.split("=")[0]] = item.split("=")[1]})
          if(typeof queryDict['cid'] != 'undefined') {
            cid = queryDict['cid'];
          }
          
          var pageTitle = '';
          var pageDesc = '';
          var pageBody = '';
          var imgSrc = '';
          var videoSrc = ''; 
          switch(cid) {
          

       case 'DigitalBestPractices':
             pageTitle = 'Best Practices in Digital Marketing for the Oil and Gas Industry';
             pageDesc = '';
             pageBody = '<p>The oil and gas industry’s marketing landscape is evolving faster than ever before.<br\><br\>Marketers have access to new digital channels that weren’t available just 10 years ago.<br\><br\>To help you stay in front of the latest digital marketing trends, Hart Energy, in partnership with Unleaded Communications, Savage Brands and Foster Marketing, collected expert insights and live campaign data for this white paper.<br></br></p><p><strong><em>This white paper will discuss best practices in the following areas:</em></strong><ul><li>Native advertising.</li><li>Video and video production.</li><li>Social media.</li><li>Banner advertising and methods to increase engagement.</li></p><p style="margin-left:-1cm"><strong></strong></p>';
             imgSrc ="{!$Resource.DigitalBestPractices}";
       break;
       
             
 default:
              cid = ''; // Protect against injection
              pageBody = '<p style="color:red; font-weight:bold;">Missing or incorrect whitepaper.</p>';
              document.getElementById('contact-form').style.display = 'none';
videoSrc = '';
              break;
          }

          
          document.getElementById('pageTitle').innerHTML = pageTitle;
          document.getElementById('pageDesc').innerHTML = pageDesc;
          document.getElementById('pageBody').innerHTML = pageBody;
          document.getElementById('theImage').setAttribute('src', imgSrc);
          
          
          if(cid != '') {
            document.getElementsByTagName('form')[0].action += '?cid=' + cid;
          }
      }
      </script>

        

      <div id="centered">
          <div id="EPheader">
            <a href="http://www.hartfuel.com" target="_parent"><img src="http://digital.hartenergy.com/img/logo.png"/></a>
          </div>
          <hr />
          <div id="pageTitle"></div>
          <div id="pageDesc"></div>
          <div id="pageBody"><p></p></div>

          <div id="picture"><p align="center"><img id='theImage' src=""/></p></div>
        
        <div id="FormCon">
                <div id="EPformHead"><img src="http://www.hartenergy.com/images/email/register.jpg"/></div>
                <div id="EPform">
                 <apex:form >
                          <apex:messages id="error" styleClass="errorMsg" layout="table" style="margin-top:1em; color:red;"/>
                          <apex:pageBlockSection title="Contact Us" collapsible="false" columns="1">
                  
                  
                  <apex:inputField required="true" value="{!Lead.FirstName}"/>
                  <apex:inputField required="true" value="{!Lead.LastName}"/>
                  <apex:inputField required="true" value="{!Lead.Email}"/>
                  <apex:inputField required="true" value="{!Lead.Company}" label="Company"/>
                  <apex:inputField required="true" value="{!Lead.Title}"/>
                  <apex:inputField required="true" value="{!Lead.Street}"/>
                  <apex:inputField required="true" value="{!Lead.City}"/>
                  <apex:inputField required="true" value="{!Lead.State_ProvinceDropdown__c}"/>
                  <apex:inputField required="true" value="{!Lead.PostalCode}"/>
                  <apex:inputField required="false" value="{!Lead.CountryDropDown__c}"/>
                  <apex:inputField required="false" value="{!Lead.Phone}"/>
                  <p>In addition to communications that may result from this inquiry, would you also like to receive news and
                   event email notifications from the sponsors that are specific to your interests? <apex:inputField value="{!Lead.WhitePaperAdditionalContact__c}"/></p>
                  <apex:commandButton value="Submit" action="{!saveLead}"/>
              </apex:pageBlockSection>
            </apex:form>
                
                
                </div>
        </div>
      </div>
    </apex:pageBlock>
  </apex:define>
</apex:page>
 
public class myWeb2LeadExtension {

 

    private final Lead weblead;



    public myWeb2LeadExtension(ApexPages.StandardController stdController) {

       weblead = (Lead)stdController.getRecord();

    }

     

     public PageReference saveLead() {

       try {
       weblead.whitepaperID__c = Apexpages.currentPage().getParameters().get('cid');

       insert(weblead);

       }

       catch(System.DMLException e) {

           ApexPages.addMessages(e);

           return null;

       }

     PageReference p = Page.ThankYouPageWhitePaper;
     p.getParameters().put('cid', Apexpages.currentPage().getParameters().get('cid'));
  

       p.setRedirect(true);

       return p;
       
    }
    
}

 
Best Answer chosen by Alfredo Ornelas 4
Pankaj_GanwaniPankaj_Ganwani
Hi Alfredo,

Try to run the page in context of the system admin with the same parameters as that of you are using in site. In this manner, you will come to know the exact cause of the issue. I suspect there would be some exception.

All Answers

Alfredo Ornelas 4Alfredo Ornelas 4
On Public Access Settings I enter the following permissions: Read,Create on Accounts and Leads. My VF pages are enabled under Site Visualforce Pages.
Pankaj_GanwaniPankaj_Ganwani
Hi Alfredo,

Try to run the page in context of the system admin with the same parameters as that of you are using in site. In this manner, you will come to know the exact cause of the issue. I suspect there would be some exception.
This was selected as the best answer
Alfredo Ornelas 4Alfredo Ornelas 4
Thanks for your help!