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" style="display:none;">
<option value="012w0000000QCbe">Prospect UK</option></select>
<select id="00N20000001L8Pi" name="00N20000001L8Pi" title="Web Source" style="display:none;"><option value="Download Whitepapers UK">Download Whitepapers UK</option> </select>
<select id="lead_source" name="lead_source" style="display:none;">
<option value="Download Whitepapers UK">Download Whitepapers UK</option></select>
<input type="submit" name="submit">
</form>
The action attribute of a <form> is basically a redirect for the form that sends the POST or GET data along with it.
If action is left blank, it redirects to the current URL, thus "refreshes".
If action is a link beginning with http:// or https://, the form sends the $_POST / $_GET request to the full page link.
If action is set to a link not beginning with http:// nor https://, 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 to https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8
Related
I have a html form with select. Based on select option i want to display a sub form with different values and insert this data to database. I figured out how to display a sub form, but i don't know how to insert different values into database. Let's say i have an option CD with value size, a BOOK with value weight and FURNITURE with three values - width, length and height. With CD and BOOK it is simple, but how do i handle furniture with three parameters?
<form class="form-group" action="" method="post">
<label for="id">SKU</label>
<input type="text" name="id" class="form-control">
<label for="name">Name</label>
<input type="text" name="name" class="form-control">
<label for="price">Price</label>
<input type="text" name="price" class="form-control">
<label for="type-switch">Type</label>
<select class="form-control" name="type-switch" id="type" onchange="changeOptions(this)">
<option value="" selected="selected"></option>
<option value="form_1">DVD</option>
<option value="form_2">Book</option>
<option value="form_3">Furniture</option>
</select>
</form>
<!-- Sub Form-->
<form class="sub-form" name="form_1">
<label for="size">Size(MB)</label>
<input class="form-control" type="text" name="size" id="">
</form>
<form class="sub-form" name="form_2">
<label for="weight">Weight(KG)</label>
<input class="form-control" type="text" name="weight" id="">
</form>
<form class="sub-form" name="form_3">
<label for="height">Height(CM)</label>
<input class="form-control" type="text" name="height" id="">
<label for="width">Width*(CM)</label>
<input class="form-control" type="text" name="width" id="">
<label for="length">Length(CM)</label>
<input class="form-control" type="text" name="length" id="">
</form>
</div>
Below is my HTML and PHP code. I'm trying to display my the inputted data, however, I'm getting nothing. What is wrong with my code?
HTML
<form action="welcome.php" method="POST">
<fieldset>
<legend> Personal Details: </legend>
<label for="fname>"></label>
<input type="text" name="Name" id="fname" required autofocus placeholder="First Name" pattern="[a-zA-Z]{3,}" title="Please enter more than three letters">
<label for="lname>"></label>
<input type="text" name="Last Name" id="lname" required autofocus placeholder="Last Name" pattern="[a-zA-Z]{3,}" title="Please enter more than three letters">
<label for="email">Email: </label>
<input type="text" name="email" id="email" required placeholder="Your school email" pattern="[a-zA-Z]{3,}#[a-zA-Z]{3,}[.]{1}[a-zA-Z{2} title="Please enter a valid email address>
<label for="phone">Phone: </label>
<input type="tel" name="phone" id="phone" required placeholder="Please enter in your phone number" pattern="[0-9]{4} [0-9]{3} [0-9]{3}" title="Please enter in a phone number in this format: #### ### ###">
<select name="country" required>
<option value=""> </option>
<option value="US">US</option>
<option value="UK">UK</option>
<option value="AUS">AUS</option>
</select>
</fieldset>
<br>
<fieldset>
<legend> Booking Details: </legend>
<input type="date" name="date" min="2018-10-07" max="2018-10-31">
<input type=time min=9:00 max=17:00 step=900>
<br>
<br>
<label for="dorm">Dormitory: </label>
<br>
<select name="dorm" required>Dormitory
<option value="Cypress">Cypress Hall</option>
</select>
<br>
<br>
<label for="floor">Floor: </label>
<br>
<select name="floor" required>Floor:
<option value=""></option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
</select>
<br>
<br>
<label for="roomnumber">Room Number: </label>
<br>
<select name="roomnumber">Room Number:
<option value=""></option>
<option value="22">22</option>
</select>
<br>
<br>
<label for="roomletter">Room Letter: </label>
<br>
<select name="roomletter" required="">Room Letter
<option value=""></option>
<option value="A">A</option>
<option value="B"> B</option>
</select>
<br>
<br>
<label for="bedroomcleaning">Bedroom: </label><br>
<input type="checkbox" id="box-4" onclick="checkPrice()" value="4">Dust all ceiling fans/light/fixtures within reach.<br>
<input type="checkbox" id="box-5" onclick="checkPrice()" value="5"> Change sheets and/or fold clothes if requested by client.<br>
<input type="checkbox" id="box-6" onclick="checkPrice()" value="6"> Straighten up, put toys away, make beds, fold clothes and put on bed. Straighten papers and put in a pile. DO NOT THROW AWAY ANY PERSONAL ITEMS!<br><br>
<label for="bathroomcleaning">Bathroom: </label><br>
<input type="checkbox" id="box-1" onclick="checkPrice()" value="1"> Clean bowl and wipe down toilet cover, seat, under seat, base and behind the base.<br>
<input type="checkbox" id="box-2" onclick="checkPrice()" value="2"> Clean all mirrors.<br>
<input type="checkbox" id="box-3" onclick="checkPrice()" value="3"> Clean countertops and backsplashes.<br>
<label for="bathroomprice" id="price">Total Price: </label>
<br>
<br>
<input type="submit">
</fieldset>
</form>
PHP
Welcome <?php echo $_POST["Name"]; ?><br>
Your email address is: <?php echo $_POST["email"]; ?>
Your phone number is: <?php echo $_POST["phone"]; ?>
Check your pattern for the email input:
[a-zA-Z]{3,}#[a-zA-Z]{3,}[.]{1}[a-zA-Z{2}
[a-zA-Z]{3,}#[a-zA-Z]{3,}[.]{1}[a-zA-Z]{2}
Also:
<input type=time min=9:00 max=17:00 step=900>
<input type="time" min="9:00" max="17:00" step="900">
As said by Jon in the comments, you need a <form> div.
<form action="yourPhpPage.php" method="POST">
<label ...>...</label>
<input ... />
...
<input type="submit" value="Send" />
</form>
The action attribute tells which page to call when submitting form.
The method tells how to send data (GET or POST mainly)
The <input type="submit" /> is the submit button. When you click it the page indicated in action will be called with the values of the different inputs. The value of the submit input is what is shown on it.
Eventually you can use a submit <button> :
<button type="submit">What you want to be displayed on it.</button>
I prefer this one because it's easier to modify its style and behavior respectively with CSS and JS. But it's not the point.
Hope it helps you !Jean-Marc.
I have the following form, how can i get the data from multiple[] arrays in the form and combine them into 3 data sets eg name[], quantity[], unit[]
<input type="text" name="name[]" class="form-control" placeholder="Name" />
<input type="text" name="name[]" class="form-control" placeholder="Name" />
<input type="text" name="name[]" class="form-control" placeholder="Name" />
<input type="text" name="quantity[]" class="form-control" />
<input type="text" name="quantity[]" class="form-control" />
<input type="text" name="quantity[]" class="form-control" />
<select name="unit[]" >
<option value="">--Unit--</option>
<option value="g">g</option>
</select>
<select name="unit[]" >
<option value="">--Unit--</option>
<option value="g">g</option>
</select>
<select name="unit[]" >
<option value="">--Unit--</option>
<option value="g">g</option>
</select>
The PHP Manual at http://php.net/manual/en/tutorial.forms.php answers your question.
Example #1 A simple HTML form
>
>
>
> <form action="action.php" method="post">
> <p>Your name: <input type="text" name="name" /></p>
> <p>Your age: <input type="text" name="age" /></p>
> <p><input type="submit" /></p>
> </form>
>
>
>
There is nothing special about this form. It is a straight HTML form
with no special tags of any kind. When the user fills in this form and
hits the submit button, the action.php page is called. In this file
you would write something like this:
Example #2 Printing data from our form
>
> Hi <?php echo htmlspecialchars($_POST['name']); ?>.
> You are <?php echo (int)$_POST['age']; ?> years old.
>
>
A sample output of this script may be:
Hi Joe. You are 22 years old.
Apart from the htmlspecialchars() and (int) parts, it should be
obvious what this does.
Do var_dump($_POST) to view all results.
in $_POST['name'] (or quantity or unit) u have an array with 3 results.
I'm trying to make a form for a user signup page however when I submit the form I keep getting a blank array. When I switched method="post" to method="get" the array was filled with the appropriate values. I have no idea what is going on!
index.html
<form action="config.php" method="POST">
<input type="text" name="firstname" placeholder="First Name">
<input type="text" name="lastname" placeholder="Last Name">
<input type="text" name="email" placeholder="Email">
<div class="select">
<select name="status">
<option selected="selected" disabled='disabled'>Status</option>
<option value="student">Student</option>
<option value="faculty">Faculty</option>
<option value="alumni">Alumni</option>
</select>
</div>
<div style="text-align: center">
<input type="submit" name="submit" value="Sign Up" class="btn large color wow center fadeInLeft">
</div>
</form>
config.php
print_r($_POST);
Result
Array ( )
I have a php file like this (HTML code is generated by web to lead from salesforce) :
<?php
module_load_include('inc', 'node', 'node.pages');
?>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">
<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">
<input type=hidden name="oid" value="00D200000000WlM">
<input type=hidden name="retURL" value="http://www.listertechnologies.com/contact-us">
<label for="first_name">First Name</label><em>*</em><input id="first_name" maxlength="40" name="first_name" size="20" type="text" required/><br>
<label for="last_name">Last Name</label><em>*</em><input id="last_name" maxlength="80" name="last_name" size="20" type="text" required/><br>
<label for="email">Email</label><em>*</em><input id="email" maxlength="80" name="email" size="20" type="text" required/><br>
<label for="company">Company</label><input id="company" maxlength="40" name="company" size="20" type="text" /><br>
Please select nature of enquiry:<em>*</em><select id="00ND0000006U5Eo" name="00ND0000006U5Eo" title="Please select nature of enquiry" required>
<option value="">--None--</option><option value="I need a solution">I need a solution</option>
<option value="I have a question">I have a question</option>
<option value="I am looking for a career opportunity">I am looking for a career opportunity</option>
</select><br>
Message:<textarea id="00ND0000006U5Et" name="00ND0000006U5Et" rows="3" type="text" wrap="soft"></textarea><br>
<input type="submit" name="submit">
</form>
I want to process some logic before sending it to salesforce. Like if it is career (one option in dropdown) then dont submit to salesforce just send mail to some department. I am new to php any help will be apprerciated,