post data to an external url in php - php

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,

Related

I very new at both html and php. This is my first time posting. Add state code dropdown list

I have a standard form with all user info, I want to have a drop down list where the state input is so the user can select the state. I have a database with state code and description. Here's the code for my form, just need to know how to add the drop down list so it will show up where the state code is. I've tried putting the drop down using the regular drop down code but when I do that the drop down list shows up at the top of the form.
<section class="main-container">
<div class="main-warpper">
<h2>Sign up</h2>
<form class="signup-form" action="includes/signupinc.php" method="POST">
<input type="text" name="mbrnumber" placeholder="Member Number">
<input type="text" name="alias" placeholder="Alias">
<input type="text" name="firstname" placeholder="First Name">
<input type="text" name="lastname" placeholder="Last Name">
<input type="text" name="address" placeholder="Address">
<input type="text" name="city" placeholder="City">
<input type="text" name="state" placeholder="State">
<input type="text" name="zipcode" placeholder="Zip Code">
<input type="text" name="email" placeholder="E-mail">
<input type="password" name="pwd" placeholder="Password">
<button = type="submit" name="submit">Sign Up</button>
</form>
</div>
</section>
I've been playing around with this and have come up with something like I want. I would like the state code drop down list to look like the placeholder in the rest of the form. Width height I know I can style this but not sure just how to do that. Here's the code I have come up with. The state drop down list comes from my database.
<section class="main-container">
<div class="main-warpper">
<h2>Sign up</h2>
<form class="signup-form" action="includes/signup.inc.php" method="POST">
<input type="text" name="clubname" placeholder="Your databae name(lower case only no spaces)">
<input type="text" name="mbrnumber" placeholder="Member Number">
<input type="text" name="alias" placeholder="Alias">
<input type="text" name="firstname" placeholder="First Name">
<input type="text" name="lastname" placeholder="Last Name">
<input type="text" name="address" placeholder="Address">
<input type="text" name="city" placeholder="City">
<tr>
<input type="text" name="state" placeholder="State">
<select name="state">
<?php
$sql="Select * from matchstates";
echo "<option value='' selected>Select State</option>";
foreach ($conn->query($sql) as $row) {
echo "<option value=$row[statecode]>$row[statename]</option>";
}
?>
</select>
</tr>
<input type="text" name="zipcode" placeholder="Zip Code">
<input type="text" name="email" placeholder="E-mail">
<input type="password" name="pwd" placeholder="Password">
<button = type="submit" name="submit">Sign Up</button>
</form>
</div>

custom php template not working on wordpress when submit form data to next page

this is from i have using in custom template
<form class="register" id="hh" method="POST" action="http://www.website.com/online-registration">
<input type="text" id="name" name="name" value="" class="register-input" placeholder="Name"/>
<input type="email" id="email" name="email" class="register-input" placeholder="Email address" required>
<input type="password" id="password" name="password" class="register-input" placeholder="Password">
<input type="text" id="mobile" name="mobile" value="" placeholder="mobile" class="register-input" required />
<input type="text" id="city" name="city" value="" placeholder="Current City" class="register-input" />
<input type="text" id="qualification" name="qualification" value="" placeholder="Qualification Details" class="register-input" />
<select id="subject" name="subject" class="register-input">
<option value=""> Please Select Type </option>
<option> Seeker </option>
<option> Employer </option>
<textarea cols="40" rows="2" placeholder="Message" class="register-input" id="message" name="message"></textarea>
<input type="submit" value="Send" name="reg" id="reg" class="register-button">
</form>
facing problem when data goes to next page
<?php /* Template Name: applyregistration */ ?>
<?php get_header(); include('conn.php'); ?>
Here i get error -Sorry, No Posts Found
<?php
include 'conn.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
}
Close Select Tag select tag.
<form class="register" id="hh" method="post" action="formaction.php">
<input type="text" id="name" name="name" value="" class="register-input" placeholder="Name"/>
<input type="email" id="email" name="email" class="register-input" placeholder="Email address" required>
<input type="password" id="password" name="password" class="register-input" placeholder="Password">
<input type="text" id="mobile" name="mobile" value="" placeholder="mobile" class="register-input" required />
<input type="text" id="city" name="city" value="" placeholder="Current City" class="register-input" />
<input type="text" id="qualification" name="qualification" value="" placeholder="Qualification Details" class="register-input" />
<select id="subject" name="subject" class="register-input">
<option value=""> Please Select Type </option>
<option> Seeker </option>
<option> Employer </option>
</select>
<textarea cols="40" rows="2" placeholder="Message" class="register-input" id="message" name="message"></textarea>
<input type="submit" value="Send" name="reg" id="reg" class="register-button">
It is the issue of name of variables that i have using in form.. just change the attributes names.. Example - name to name1, email to email1..etc etc..
Problem Solved
this link is very useful to create customized form in WordPress https://www.inkthemes.com/how-you-can-easily-create-customized-form-in-wordpress/

PHP action / salesForce

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

AngularJS, Databind Multiple Form Fields

Ok i have a Edit Form in AngularJS and i want show data in textboxes through angular databindings.
Here is the Form which i have done so far.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
<link href="<?php echo base_url(); ?>/styles/formcss.css" rel="stylesheet" type="text/css"/>
<script src="<?php echo base_url(); ?>/scripts/angular.min.js"></script>
</head>
<body ng-app>
<div ng-controller="controller">
<form>
<label for="name">UserID:</label> <input type="text" name="UserID" ng-model="user.UserID" value=""><br>
<label for="UserName">Name:</label> <input type="text" name="UserName" ng-model="user.UserName" value=""><br>
<label for="rollno">In Game Name:</label> <input type="text" name="GameName" ng-model="user.InGameName" value="" ><br>
<label for="father">CNIC Number:</label> <input type="number" name="Cnic" ng-model="user.Cnic" value="" ><br>
<label for="age">Age:</label> <input name="Age" ng-model="user.Age" type="number" value="" ><br>
<label for="email1">Email:</label> <input name="Email" ng-model="user.Email" type="email" value="" ><br>
<label for="email2">Res enter Email:</label> <input id="email2" type="email" name="email2" value="" ><br>
<label for="pass1">Password:</label> <input id="pass1" type="password" name="Pass" ng-model="user.Password" value=""><br>
<label for="pass2">Re enter Password:</label> <input id="pass2" type="password" name="pass2" value="" ><br>
<label style="margin-bottom:-10px; " for="male">Male</label><input class="gen" ng-model="user.Gender" id="male" type="radio" name="g" value="Male"><br>
<label style="margin-bottom:15px;" for="female">Female</label><input class="gen" ng-model="user.Gender" id="female" type="radio" name="g" value="Female"><br>
<label class="dis" for="about" >About:</label> <textarea rows="5" cols="40" id="about" type="text" value=""></textarea><br>
<button style="margin-left: 225px;" ng-click="save()" >Save</button>
</form>
</div>
<script>
function controller ($scope,$http)
{
var angularform="<?php echo base_url(); ?>index.php/datacon/angform"
$scope.save=function()
{
$http.post(angularform, $scope.user);
}
}
</script>
</body>
</html>
Here is the Json Array I am Getting From the Controller
JSON:
{"datas":[{"UserID":"168","UserName":"fdaa","Cnic":"23424","Email":"pak#gmail.com","Password":"asdad","Age":"12","Gender":"Male","Picture":null,"InGameName":"fds","ContactID":null,"GroupID":null,"ClanID":null}]}
But How to show these values in TextBoxes through Angular Data bindings?
Or if i am Doing Something Wrong Please Redirect me to my mistakes so i could solve my mistakes.
I am not sure whether I am getting you right or not. But I think If you are using $scope and ng-model, they are doing their job perfectly. You are using absolutely correct.
With the $http.post() you can save the data. At the same time data will be present in the text boxes.
What exactly you want to do. Please explain a bit more so that folks can try to explain you more.

Append variables to url after form submit

I have this Landing Page that I need to pre-populate with form values after it is submitted. Essentially in the end I have to make the url look like this...
http://example.com/r.php?sid=xx&pub=xxxxx&c1=&c2=&c3=&append=1&firstname=Test&lastname=Smith&address=2211+Commerce+St.&city=Dallas&state=TX&zipcode=75080&email=test#test.com
What I currently have now for the form is...
<form name="regForm" method="get" action="http://example.com/r.php?sid=xx&pub=xxxx&c1=&c2=&c3=&append=1">
<input id="firstname" class="text" type="text" name="firstname"/><br>
<input id="lastname" class="text" type="text" name="lastname" /><br>
<input id="email" class="text" type="text" name="email" /><br>
<input id="address" class="text" type="text" /><br>
<input id="city" class="text" type="text"/><br>
<input id="zipcode" class="text" type="text" maxlength="5" name="zipcode" /><br>
<input type="submit" value="Send Me My FREE List" id="submitBtn2"/>
</form>
How do i create that URL above after the form is submitted? I have been racking my brain all day on this and can't figure it out, i feel like im close.
thanks for the help!
Include the extra parameters as hidden form fields instead of inline query parameters:
<form name="regForm" method="get" action="http://example.com/r.php">
<input type="hidden" name="sid" value="xx" />
<input type="hidden" name="pub" value="xxxx" />
<input type="hidden" name="c1" value="" />
<input type="hidden" name="c2" value="" />
<input type="hidden" name="c3" value="" />
<input type="hidden" name="append" value="1" />
<input id="firstname" class="text" type="text" name="firstname"/><br>
<input id="lastname" class="text" type="text" name="lastname" /><br>
<input id="email" class="text" type="text" name="email" /><br>
<input id="address" class="text" type="text" /><br>
<input id="city" class="text" type="text"/><br>
<input id="zipcode" class="text" type="text" maxlength="5" name="zipcode" /><br>
<input type="submit" value="Send Me My FREE List" id="submitBtn2"/>
</form>
The problem is the input field get variables are causing your url get variables to be truncated, put all your url parameters as hidden values.
<input id="pub" type="hidden" name="pub" value=""/>
<input id="sid" type="hidden" name="sid" value=""/>
I'm assuming that you like the URL that it generates except that you're missing the sid, pub, c1, c2, c3, and append variables. If so, just make hidden inputs like this:
<form id="regForm" ...>
<input id="sid" name="sid" value="" type="hidden" />
<input id="pub" name="pub" value="" type="hidden" />
...
</form>
If you know the values while you're creating the form, then you can do it on the server side. If you don't, then assuming you're using jQuery, you will have to do something like this:
$(function() {
$('#regForm').submit(function () {
$('#sid').val('myNewSidValue');
$('#pub').val('myNewPubValue');
...
});
});

Categories