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
Jezza83Jezza83 

Submit on Sites form but receive error: Authorization Required

I have created a web2contact form using Sites however whenever you submit on the form you are presented with an "Authorization Required" error message.

 

Has anyone else come across this before ? 

 

I have checked everything including the Guest User Profile permissions, field level security on Contacts object etc. but all looks fine.

 

Really appreciate any help with this one !

BulentBulent

can you share your page and controller source code?

Jezza83Jezza83

Hi Bulent,

 

Thanks for your help ! Absolutely the page URL is - http://mab.force.com/brandjunction

 

and the source code is below (please don't cringe too much);

 

 

<apex:page showHeader="false" id="brandJunction" extensions="myMethod" standardController="Contact">

  <apex:insert name="body"/>

<html>

<head>

<meta http-equiv="Content-Language" content="en-au">

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>Brand Junction VIP Members Form</title>

<style type="text/css">
*{margin:0;padding:0;}
form{padding:10px}
#submitbox{margin:10px 0 0 180px;width:90px;}
.checkboxes{width:1em;}
.required{border-left:3px solid #ff0000 !important}
.optional{border-left:3px solid #cccccc !important}
.error{border:1px solid #ff0000;}
label.error{display:block;width:200px;font-size:10px;color:red;margin:-7px 0 -15px 180px;border:0;float:none}
br{clear:left;}
.h3{color: rgb(71, 70, 69); font-family: Arial, Helvetica, Verdana; font-size: 11px; font-weight: bold; text-align: left;}
.options{color: rgb(71, 70, 69); font-family: Arial, Helvetica, Verdana; font-size: 11px; text-align: left;}
.input{font-size: 11px; width: 135px; height: 18px;background:#f2fce4; border: solid 1px #ccc!Important;}
.input1{font-size: 11px; width: 135px; height: 18px;background:#ffffff; border: solid 1px #ccc!Important;}
.input2{font-size: 12px; width: 400px; height: 25px;background:#ffffff; border: solid 1px #ccc!Important;}
.smallgreentext {font-size:10px; color: #598d14;}
</style>

<script type="text/javascript" src="jquery/jquery-1.2.6.pack.js"></script>
<script>
 $(document).ready(function(){
   $("#w2x-form").validate();
   $.validator.addMethod('sqldate', function(value,element) {return this.optional(element) || /^([0-9]{4})-([0-1][0-9])-([0-3][0-9])$/.test(value);}, 'Use the format YYYY-MM-DD');
   $.validator.addMethod('sqldatetime', function(value,element) {return this.optional(element) || /^([0-9]{4})-([0-1][0-9])-([0-3][0-9])T([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])Z$/.test(value);}, 'Use the format YYYY-MM-DDThh:mm:ssZ');
 });
</script>


</head>

<body>

<div align="center"><br/>
    <table border="0" width="600" cellspacing="0" cellpadding="0">
    <apex:form id="theForm" onsubmit="myReturn()">
    <input type="hidden" name="retURL" value="http://www.prmaustralia.com.au/MAB/Brand_Junction_VIP/Brand_Junction_Membership_Thankyou.html">
    <input type="hidden" name="sObj" value="Contact">
    <input  id="00N20000002DYZv" name="00N20000002DYZv" type="hidden" value="brandjunction.com.au"/>
    <input  id="00N20000002DYc6" name="00N20000002DYc6" type="Hidden" value="Web Form"/>
    
        <tr>
            <td align="left" width="20%" height="25" valign="top"><span class="options">Title:</span></td>
            <td align="left" width="30%" height="25" valign="top"><apex:inputField value="{!Contact.Salutation}" styleClass="input"/></td>
            <td align="left" width="20%" height="25" valign="top">&nbsp;</td>
            <td align="left" width="30%" height="25" valign="top">&nbsp;</td>
        </tr>
        <tr>
            <td align="left" width="20%" height="25" valign="top"><span class="options">First Name:</span></td>
            <td align="left" width="30%" height="25" valign="top"><apex:inputField value="{!Contact.FirstName}" styleClass="input"/><span class="smallgreentext"> *</span></td>
            <td align="left" width="20%" height="25" valign="top"><span class="options">Last Name:</span></td>
            <td align="left" width="30%" height="25" valign="top"><apex:inputField value="{!Contact.LastName}" styleClass="input"/><span class="smallgreentext"> *</span></td>
        </tr>
        <tr>
            <td align="left" width="20%" height="25" valign="top"><span class="options">Street Address:</span></td>
            <td align="left" width="30%" height="25" valign="top"><input type="text" id="MailingStreet" name="MailingStreet" class="input" maxlength="40" /><span class="smallgreentext"> *</span></td>
            <td align="left" width="20%" height="25" valign="top"><span class="options">Suburb:</span></td>
            <td align="left" width="30%" height="25" valign="top"><input type="text" id="MailingCity" name="MailingCity" class="input" maxlength="40" /><span class="smallgreentext"> *</span></td>
        </tr>
        <tr>
            <td align="left" width="20%" height="25" valign="top"><span class="options">State:</span></td>
            <td align="left" width="30%" height="25" valign="top"><select id="MailingState" name="picklist_MailingState" class="input">
            <option value="">- select -</option>
            <option value="VIC">VIC</option>
            <option value="NSW">NSW</option>
            <option value="QLD">QLD</option>
            <option value="SA">SA</option>
            <option value="WA">WA</option>
            <option value="TAS">TAS</option>
            <option value="TAS">ACT</option>
            <option value="TAS">NT</option></select><span class="smallgreentext"> *</span></td>
            <td align="left" width="20%" height="25" valign="top"><span class="options">Postcode:</span></td>
            <td align="left" width="30%" height="25" valign="top"><input type="text" id="MailingPostalCode" name="string_MailingPostalCode" class="input" maxlength="20" /><span class="smallgreentext"> *</span></td>
        </tr>
        <tr>
            <td align="left" width="20%" height="25" valign="top"><span class="options">Phone:</span></td>
            <td align="left" width="30%" height="25" valign="top"><input type="text" id="HomePhone" name="string_HomePhone" class="input" maxlength="40" /><span class="smallgreentext"> *</span></td>
            <td align="left" width="20%" height="25" valign="top"><span class="options">Email:</span></td>
            <td align="left" width="30%" height="25" valign="top"><input type="text" id="Email" name="email_Email" class="input" maxlength="80" /><span class="smallgreentext"> *</span></td>
        </tr>
        <tr>
            <td align="left" width="20%" height="25" valign="top"><span class="options">Gender:</span></td>
            <td align="left" width="30%" height="25"><span class="options"><input type="radio" name="radio_Gender__c" value="Male" /> Male
            <input type="radio" name="radio_Gender__c" value="Female" /> Female<span class="smallgreentext"> *</span></td>
            <td align="left" width="20%" height="25" valign="top"><span class="options">Date of Birth: (yyyy/mm/dd)</span></td>
            <td align="left" width="30%" height="25" valign="top"><input type="text" id="Birthday__c" name="date_Birthday__c" class="input" maxlength="20" /><span class="smallgreentext"> *</span></td>
        </tr>
    </table><br/><br/>
    <table border="0" width="600" cellspacing="0" cellpadding="0">
        <tr>
            <td align="left" width="99%" height="23" colspan="3" valign="top"><span class="h3">Where else do you shop ?</span></td>
        </tr>
        <tr>
            <td align="left" width="33%" height="20"><input type="checkbox" name="Person_Shops_t__c" value="Westfield Plenty Valley" /><span class="options"> Westfield Plenty Valley</span></td>
            <td align="left" width="33%" height="20"><input type="checkbox" name="Person_Shops_t__c" value="Brand Smart" /><span class="options"> Brand Smart</span></td>
            <td align="left" width="33%" height="20"><input type="checkbox" name="Person_Shops_t__c" value="Greensborough Plaza" /><span class="options"> Greensborough Plaza</span></td>
        </tr>
        <tr>
            <td align="left" width="33%" height="20"><input type="checkbox" name="Person_Shops_t__c" value="Epping Plaza" /><span class="options"> Epping Plaza</span></td>
            <td align="left" width="33%" height="20"><input type="checkbox" name="Person_Shops_t__c" value="DFO Essential" /><span class="options"> DFO Essential</span></td>
            <td align="left" width="33%" height="20"><input type="checkbox" name="Person_Shops_t__c" value="Northland Shopping Centre" /><span class="options"> Northland Shopping Centre</span></td>
        </tr>
        <tr>
            <td align="left" width="33%" height="20"><input type="checkbox" name="Person_Shops_t__c" value="DFO Spencer Street" /><span class="options"> DFO Spencer Street</span></td>
            <td align="left" width="33%" height="20"><input type="checkbox" name="Person_Shops_t__c" value="Other" /><span class="options"> Other</span></td>
            <td align="left" width="33%" height="20"><input type="text" id="Person_Shops_At_Other__c" name="string_Person_Shops_At_Other__c" class="input1" maxlength="40" /></td>
        </tr>
    </table><br/><br/>
    <table border="0" width="600" cellspacing="0" cellpadding="0">
        <tr>
            <td align="left" width="99%" height="23" colspan="3" valign="top"><span class="h3">What Products do you regularly shop for ?</span></td>
        </tr>
        <tr>
            <td align="left" width="33%" height="20"><input type="checkbox" name="Product_Interest__c" value="Mens Fashion" /><span class="options"> Mens Fashion</span></td>
            <td align="left" width="33%" height="20"><input type="checkbox" name="Product_Interest__c" value="Sports & Streetwear" /><span class="options"> Sports & Streetwear</span></td>
            <td align="left" width="33%" height="20"><input type="checkbox" name="Product_Interest__c" value="Homewares" /><span class="options"> Homewares</span></td>
        </tr>
        <tr>
            <td align="left" width="33%" height="20"><input type="checkbox" name="Product_Interest__c" value="Womens Fashion" /><span class="options"> Womens Fashion</span></td>
            <td align="left" width="33%" height="20"><input type="checkbox" name="Product_Interest__c" value="Lingerie/Sleepwear" /><span class="options"> Lingerie/Sleepwear</span></td>
            <td align="left" width="33%" height="20"><input type="checkbox" name="Product_Interest__c" value="Home Fashion" /><span class="options"> Home Fashion</span></td>
        </tr>
        <tr>
            <td align="left" width="33%" height="20"><input type="checkbox" name="Product_Interest__c" value="Childrens Fashion" /><span class="options"> Childrens Fashion</span></td>
            <td align="left" width="33%" height="20"><input type="checkbox" name="Product_Interest__c" value="Jewellery/Accessories" /><span class="options"> Jewellery/Accessories</span></td>
            <td align="left" width="33%" height="20"><span class="options">&nbsp;</span></td>
        </tr>
        <tr>
            <td align="left" width="33%" height="20"><input type="checkbox" name="Product_Interest__c" value="Other" /><span class="options"> Other </span></td>
            <td align="left" width="33%" height="20"><span class="options"><input type="text" id="Product_Interest_Other__c" name="string_Product_Interest_Other__c" class="input1" maxlength="40" /></span></td>
            <td align="left" width="33%" height="20"><span class="options">&nbsp;</span></td>
        </tr>
    </table><br/><br/>
    <table border="0" width="600" cellspacing="0" cellpadding="0">
        <tr>
            <td align="left" width="99%" height="23" colspan="3" valign="top"><span class="h3">Please describe what household you live in</span></td>
        </tr>
        <tr>
            <td align="left" width="33%" height="20"><input type="radio" name="Household_Type__c" value="Live Alone" /><span class="options"> Live Alone</span></td>
            <td align="left" width="33%" height="20"><input type="radio" name="Household_Type__c" value="Live with 1 Other Adult / Partner" /><span class="options"> Live with 1 other adult/partner</span></td>
            <td align="left" width="33%" height="20"><input type="radio" name="Household_Type__c" value="Live with 2 or More Adults" /><span class="options"> Live with 2 or more adults</span></td>
        </tr>
        <tr>
            <td align="left" width="33%" height="20"><input type="radio" name="Household_Type__c" value="Live with children and partner" /><span class="options"> Live with children and partner</span></td>
            <td align="left" width="33%" height="20"><input type="radio" name="Household_Type__c" value="Live with children only" /><span class="options"> Live with children only</span></td>
            <td align="left" width="33%" height="20"><span class="options"></span></td>
        </tr>
        <tr>
            <td align="left" width="33%" height="20"><input type="radio" name="Household_Type__c" value="Other" /><span class="options"> Other</span></td>
            <td align="left" width="33%" height="20"><input type="text" id="Household_Type_Other__c" name="string_Household_Type_Other__c" class="input1" maxlength="40" /></td>
            <td align="left" width="33%" height="20"><span class="options">&nbsp;</span></td>
        </tr>
    </table><br/><br/>
    <table border="0" width="600" cellspacing="0" cellpadding="0">
        <tr>
            <td align="left" height="20"><span class="h3">What products would you like to see at Brand Junction ?</span></td>
        </tr>
        <tr>
            <td align="left" height="20"><input type="text" id="Products_you_would_like_at_BJ__c" name="string_Products_you_would_like_at_BJ__c" class="input2" maxlength="40" /></td>
        </tr>
        <tr>
            <td align="left" height="60" valign="bottom">
            <apex:commandButton action="{!save}" image="http://www.prmaustralia.com.au/MAB/Brand_Junction_VIP/btn_register_on.gif" /><input type="image" name="submit" border="0" src="" width="81" height="30"></td>
        </tr>
    </table>

</div>
</apex:form>

</body>

</html>
  
</apex:page>

 and the simple controller to redirect to the thank-you page;

 

 

public class myMethod{

  ApexPages.StandardController controller;

    public myMethod(ApexPages.StandardController con){

    controller = con;

    }
 

  public PageReference save() {

    controller.save();

    return page.myThankyouPage;

  }
}

 

 

 

Philip_FPhilip_F

Hey JDog, Did you end up finding out what was going on here?  

 

Cheers,

-Philip

BulentBulent

can you try the following?

1- search the "Preview as admin" feature in online help

2- add the preview as admin tags to your error pages

3- test your page via the preview as admin link on the site details page. 

 

You'll see the exact error

 

 

saharisahari

Hi

 

I had a similar porblem. I forgot to add those vf pages into sites pages. And this caused all the problem. May be you should check that.