我创建了一个'联系我们'工作组中的SharePoint表单。我使用HTML创建了这个,并为后端创建了一个PHP脚本,将表单发送到我的电子邮件地址。如何将此PHP插入SharePoint以使其有效?下面是HTML和PHP代码。
<span style="color: #00cc99; font-size: 15pt;"><span style="color: #00cc99;">Contact Us if you're interested in volunteering with Social Innovation. </span></span></p>
<table width="450">
<tbody>
<tr>
<td valign="top">
<label>Name *</label> </td>
<td valign="top">
<input type="text" size="30" maxlength="50"/>
</td>
</tr>
<tr>
<td valign="top">
<label>Email Address *</label> </td>
<td valign="top">
<input type="text" size="30" maxlength="80"/>
</td>
</tr>
<tr>
<td valign="top">
<label>Message *</label> </td>
<td valign="top">
<textarea maxlength="1000" rows="6" cols="25"></textarea> </td>
</tr>
<tr>
<td colspan="2" style="text-align: center;">
<input type="button" value="Submit"/>
</td>
</tr>
</tbody>
</table>
<p> </p>
<?php
if(isset($_POST['email'])) {
// CHANGE THE TWO LINES BELOW TO SUSANNAH
$email_to = "example@email.co.uk";
$email_subject = "Sharepoint Volunteer Enquiry";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['email']) ||
!isset($_POST['message'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$message = $_POST['message']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name)) {
$error_message .= 'The Name you entered does not appear to be valid.<br />';
}
if(strlen($message) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name: ".clean_string($name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Message: ".clean_string($message)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
//thank you message
Thank you for contacting us. We will be in touch with you very soon.
<?php
}
die();
?>
答案 0 :(得分:0)
Sharepoint Site using PHP code
我使用Page Viewer WebPart就像他们在这篇文章中建议的那样做了。
但由于这篇文章已有5年历史,现在可能有一个免费的php-viewer Webpart(因为有一个HTML-Viewer)