this->setWindowOpacity(0.5);
我正在尝试添加的代码(
<?php
// Function that validates your formfields and generate errors
function validate($name, $email)
{
$errors = array();
// validation for name
if(strlen($name) < 2)
$errors[] = 'You did not enter a name.';
// validation for email
if(!strlen($email))
$errors[] = 'non-valid email.';
else if(!filter_var($email, FILTER_VALIDATE_EMAIL))
$errors[] = 'valid email.';
// return array with errors
return $errors;
}
// initialization of variables with default values
$name = '';
$email = '';
$errors = array();
// if the form has been submited
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
// overwrite the variables with the $_POST elements
$name = $_POST['name'];
$email = $_POST['email'];
)
$recipient = 'example@gmail.com';
$subject = 'Simple Forms';
$mailheader = 'From: $email \r\n';
$formcontent = '$name, $email';
我正在尝试添加的代码(
// validate the variables
$errors = validate($name, $email);
// If there aren't any errors redirect to another page
if(!count($errors))
{
// Here comes the place to send an email!!!
)
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
电子邮件正确地发送给收件人并使用正确的主题行,但它来自$ email rn,电子邮件的正文为:$ name,$ email。
示例电子邮件)
来自:$ email rn to:example@gmail.com 简单表格
$ name,$ email
它非常接近工作,但我不确定如何正确使用$ name和$ email变量。任何建议将不胜感激。