如何制作这些“联系表格”字段?

时间:2013-09-12 21:47:05

标签: php forms contact

<?php
$youremail  = "info@mainmanfilms.com";
$author   = $_POST['author'];
$email      = $_POST['email'];
$subject   = $_POST['subject'];
$text   = $_POST['text'];


if($send = "yes") {
    $content    = "Thank you for contacting Main Man Films!

Main Man Films成立于1999年,是一家活跃于电视/电影行业的国际制片人,作家,导演,演员和技术人员联盟。 MMF直接与知名人才(演员,制片人,音乐家,作曲家等)和其他行业专业人士(包括经销商和辛迪加)联系在一起。无论您有想法,完成的脚本还是“生产”计划,我们的团队都可以帮助您将项目从概念转变为分销。 MMF在美国,日本,伯利兹,英国开展了项目,并在南非,巴林和新加坡共同制作了项目。“;

    $headers    = "From: $email";
    @mail($email, 'Mail Notification | Main Man Films', $content, $headers);
}
    $headers    = "From: $email";
    $content = "Hello there! This is a message from your contact form.\r\n
    \r\n
    Name: $author\r\n
    E-mail: $email\r\n
    Subject: $subject\r\n
    \r\n
    Message: $text\r\n\r\n";
    $send = mail($youremail, 'Message from your contact form', $content, $headers);
    if($send)    {
        header("location:contact-form-thank-you.html");
        exit;
    }
    else {
        header("location:error.php");
        exit;
    }
?>

1 个答案:

答案 0 :(得分:2)

假设相关字段是作者,电子邮件,主题和文本,那么您将为每个字段运行验证脚本以确保其中包含内容

$error = array();
if(empty($_POST['author'])) $error[] = 'Please enter author';

if(count($error)==0) {

//run script

}

首先,您将错误变量设置为数组,并且每当任何验证失败时,您都会添加到数组中,如果数组中没有错误,则运行该脚本。

相关问题