PHP form to SharePoint 2010

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

I'm having trouble figuring out a solution to a minor problem: how to get a form submission into SharePoint from our website. If we were using a Windows Server, I believe we could use InfoPath Form Services. But we're using using LAMP with Drupal 7 CMS and so there does not seem to be a solution out there after extensive searching ... I may just be using the wrong terminology during search?!

So the ultimate goal is to get a form submitted into a list, that can then kick off a workflow that ends in MS Dynamics CRM. Right now I'm just concerned with getting the form data into a SP2010 list or similar.

Each form entry should be recorded in SharePoint as an item so that it can searched for and differentiated between. That is why I believe a SharePoint list or form library would work. I am just lacking in experience with SharePoint to know the correct solution.

I'd like to know how you believe this could work, if at all. Possible solutions I've been floating around include creating a PHP form that posts to XML, then emails the XML file to a SharePoint list. But I'm lacking knowledge on the SharePoint side as to how to parse that back out into list items. So any solutions or ideas are welcomed!

profilepic.png
manpreet 2 years ago

Using an example from David Dudok de Wit as a starting point, I managed to get a PHP form to populate a SharePoint List. This is entirely extensible, but for the brevity this example includes 5 fields/columns only.

The following is all in one document, but I've broken it into two for readability.

if(isset($_POST['submit'])) {

    $title      = $_POST['title'];     
    $firstName  = $_POST['firstName'];
    $lastName   = $_POST['lastName']; 
    $age        = $_POST['age'];
    $phone      = $_POST['phone'];
}

// Requires the NuSOAP library
require_once('lib/nusoap.php');

// Authentication details
$username       = 'DOMAIN\username';
$password       = 'password';
$rowLimit       = '150';

/* A string that contains either the display name or the GUID for the list.
 * It is recommended that you use the GUID, which must be surrounded by curly
 * braces ({}).
 */
$listName = "{YOUR-GUID}";

/*
 * Example field (aka columns) names and values, that will be used in the
 * CAML query. The values are the attributes of a single list item here.
 * If the field name contains a space in SharePoint, replace it
 * here with _x0020_ (including underscores).
 */
$field1Name = "Title";
$field2Name = "forename";
$field3Name = "lastname";
$field4Name = "age";
$field5Name = "phone";

$field1Value = $title;
$field2Value = $firstName;
$field3Value = $lastName;
$field4Value = $age;
$field5Value = $phone;

/* Local path to the Lists.asmx WSDL file (localhost). You must first download
 * it manually from your SharePoint site (which should be available at
 * yoursharepointsite.com/subsite/_vti_bin/Lists.asmx?WSDL)
*/
$wsdl = "./Lists.asmx?WDSL";

// Basic authentication is normally used when using a local copy a the WSDL. Using UTF-8 to allow special characters.
$client = new nusoap_client($wsdl, true);
$client->setCredentials($username,$password);
$client->soap_defencoding='UTF-8';

// CAML query (request), add extra Fields as necessary
$xml ="
 
 $listName
 
 
 
 $field1Value
 $field2Value
 $field3Value
 $field4Value
 $field5Value
 
 
 
 
";

//Invoke the Web Service
$result = $client->call('UpdateListItems', $xml);

?>

HTML



</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; box-sizing: inherit; color: #303336;">Submit Form to SharePoint List</span><span class="tag" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; box-sizing: inherit; color: #7d2727;">

                    
                    

                    

                    
tuteehub community

Join Our Community Today

Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.

tuteehub community