我在我的网站上设置了此表单:http://cssrevolt.com/upload/files/protoform/
所有这些都是定制和工作,就像上面的独立演示一样。
原型带有send.php
文件,其中包含以下PHP:
<?php
echo "<div id=\"response\">";
$name = $_POST['name'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$preference = $_POST['preference'];
$message = $_POST['message'];
if ( ($name=='') && ($email=='') && ($telephone=='') && ($message=='')) {
echo "<p>Please fill all the required fields<span>*</span></em></p>";
}
else {
echo "<p>Submitting ok, server response:</p>";
echo "<ul>";
echo "<li>Name: ".$name."</li>";
echo "<li>E-mail: ".$email."</li>";
echo "<li>Telephone: ".$telephone."</li>";
echo "<li>Preference: ".$preference."</li>";
echo "<li>Message:".$message."</li>";
echo "</ul>";
}
echo "</div>";
?>
我仍然相当熟悉PHP,但从它看起来我应该只需要插入一些代码来将数据吐出到定义的电子邮件地址,对吗?
!更新:下面的代码尝试仍然无法将表单数据发送到我的电子邮件。 (用实际替换了你的邮件)
<?php
echo "<div id=\"response\">";
$name = $_POST['name'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$preference = $_POST['preference'];
$message = $_POST['message'];
if ( ($name=='') && ($email=='') && ($telephone=='') && ($message=='')) {
echo "<p>Please fill all the required fields<span>*</span></em></p>";
}
else {
echo "<p>Submitting ok, server response:</p>";
echo "<ul>";
echo "<li>Name: ".$name."</li>";
echo "<li>E-mail: ".$email."</li>";
echo "<li>Telephone: ".$telephone."</li>";
echo "<li>Preference: ".$preference."</li>";
echo "<li>Message:".$message."</li>";
echo "</ul>";
// Body of message
$message = "Submitting ok, server response: \n
Name: $name \n
E-mail: $email \n
Telephone: $telephone \n
Preference: $preference \n
Message: $message \n";
//Recipient
$to = "your@email.dom";
//Subject of email
$subject = "Message from $name";
// http://php.net/manual/en/function.mail.php
mail($to, $subject, $message);
}
echo "</div>";
?>
推导此问题:https://stackoverflow.com/questions/9253461/using-protoform-where-is-data-via-ajax-at
答案 0 :(得分:1)
<?php
echo "<div id=\"response\">";
$name = $_POST['name'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$preference = $_POST['preference'];
$message = $_POST['message'];
if ( ($name=='') && ($email=='') && ($telephone=='') && ($message=='')) {
echo "<p>Please fill all the required fields<span>*</span></em></p>";
}
else {
echo "<p>Submitting ok, server response:</p>";
echo "<ul>";
echo "<li>Name: ".$name."</li>";
echo "<li>E-mail: ".$email."</li>";
echo "<li>Telephone: ".$telephone."</li>";
echo "<li>Preference: ".$preference."</li>";
echo "<li>Message:".$message."</li>";
echo "</ul>";
// Body of message
$message = "Submitting ok, server response: \n
Name: $name \n
E-mail: $email \n
Telephone: $telephone \n
Preference: $preference \n
Message: $message \n";
//Recipient
$to = "your@email.dom";
//Subject of email
$subject = "Message from $name";
// http://php.net/manual/en/function.mail.php
mail($to, $subject, $message);
}
echo "</div>";
?>