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 ="
<UpdateListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>
<listName>$listName</listName>
<updates>
<Batch ListVersion='1' OnError='Continue'>
<Method Cmd='New' ID='1'>
<Field Name='$field1Name'>$field1Value</Field>
<Field Name='$field2Name'>$field2Value</Field>
<Field Name='$field3Name'>$field3Value</Field>
<Field Name='$field4Name'>$field4Value</Field>
<Field Name='$field5Name'>$field5Value</Field>
</Method>
</Batch>
</updates>
</UpdateListItems>
";
//Invoke the Web Service
$result = $client->call('UpdateListItems', $xml);
?>
HTML
<!DOCTYPE html>
<head>
<title>Submit Form to SharePoint List</title>
<style>
*{
padding:0;
margin:0;
}
body{
text-align:center;
font:11px "Lucida Grande",Arial,sans-serif;
}
#content{
width:300px;
text-align:left;
margin:10px;
}
.formitem{
width:100%;
padding: 6px;
font:11px "Lucida Grande",Arial,sans-serif;
}
</style>
</head>
<body>
<div id="content">
<form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']);?>">
<label for="name">Title: </label><input class="formitem" id="title" name="title" type="text" length="10" >
<label for="name">First Name: </label><input class="formitem" id="firstName" name="firstName" type="text" length="25" >
<label for="name">Last Name: </label><input class="formitem" id="lastName" name="lastName" type="text" length="25" >
<label for="name">Age: </label><input class="formitem" id="age" name="age" type="text" length="2" >
<label for="name">Phone: </label><input class="formitem" id="phone" name="phone" type="text" length="14" >
<input type="hidden" name="submitted" value="1">
<input type="submit" name="submit" value="Submit">
</form>
</div>
</body>
</html>