ajax - PHP action / salesForce

19

I have been asked to update a contact form, i always leave action blank(action="") in any forms i have worked on before. I have been sent the following form as seen below. When the form is submitted, it is sent to the url, which is a blank screen. Has anyone implemented a salesForce contact form before ?

<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">

  <input type=hidden name="oid" value="00D200000005wgb">
  <input type=hidden name="retURL" value="http://"> <!--  add URL of completed page here    

-->

  <label for="first_name">First Name</label><input id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br>

  <label for="last_name">Last Name</label><input id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br>

  <label for="email">Email Address</label><input id="email" maxlength="80" name="email" size="20" type="text" /><br>

  <label for="phone">Phone</label><input id="phone" maxlength="40" name="phone" size="20" type="text" /><br>

   <select id="country" name="country" title="country">
    <option value="London">London</option>
    <option value="Midlands">Midlands</option>
    <option value="North England">North England</option>
    <option value="South England">South England</option>
    <option value="Wales">Wales</option>
    <option value="Scotland">Scotland</option>
    <option value="Northern Ireland">Northern Ireland</option>
   </select><br>


   <textarea id="00N200000016Kk5" name="00N200000016Kk5" rows="4" type="text" wrap="soft"></textarea><br>

   <!-- Below 3 fields are hidden -->
   <select id="recordType" name="recordType" >
    <option value="012w0000000QCbe">Prospect UK</option></select>
    <select id="00N20000001L8Pi" name="00N20000001L8Pi" title="Web Source" ><option value="Download Whitepapers UK">Download Whitepapers UK</option>  </select> 
   <select id="lead_source" name="lead_source" >
   <option value="Download Whitepapers UK">Download Whitepapers UK</option></select>


   <input type="submit" name="submit">

  </form>
973

Answer

Solution:

Theaction attribute of a<form> is basically a redirect for the form that sends the POST or GET data along with it.

  1. If action is left blank, it redirects to the current URL, thus "refreshes".
  2. If action is a link beginning withhttp:// orhttps://, the form sends the$_POST /$_GET request to the full page link.
  3. If action is set to a link not beginning withhttp:// norhttps://, the link set in the action is added to the current sub-directory in the same way a php include works.

Therefore, this in your code:

<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">

Will send a POST request tohttps://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8

People are also looking for solutions to the problem: php - How would you handle different error responses for different routes using Laravel

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.