联系表单php帮助

联系表单php帮助,php,contact,Php,Contact,好的,我有我们的联系方式,工作正常,处理正确。我有两个问题 在联系人表单页面上,我希望添加一个复选框,供用户勾选以向他们发送电子邮件副本 在流程表单部分,如果出现严重错误,我想重定向到错误页面 目前在我的表单提交中,我有一个动作要去thankyou.php 我在thankyou.php页面中添加了我的表单流程,但如果需要,可以单独将其拉出 我的表单流程如下(非常简单) 如果要发送邮件副本,则需要为邮件添加适当的标题,如: $headers = 'MIME-Version: 1.0' . "

好的,我有我们的联系方式,工作正常,处理正确。我有两个问题

  • 在联系人表单页面上,我希望添加一个复选框,供用户勾选以向他们发送电子邮件副本

  • 在流程表单部分,如果出现严重错误,我想重定向到错误页面

  • 目前在我的表单提交中,我有一个动作要去thankyou.php

    我在thankyou.php页面中添加了我的表单流程,但如果需要,可以单独将其拉出

    我的表单流程如下(非常简单)


    如果要发送邮件副本,则需要为邮件添加适当的标题,如:

    
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'To: Somename <some_email@example.com>' . "\r\n";
    $headers .= 'Cc: '.$yourCopyMail . "\r\n"; // this is for copy
    //then
    if(mail(....)) {
      echo "sent";
    }
    else {
      header("Location: url_to_your_error_page");
      exit;
    }
    
    
    $headers='MIME版本:1.0'。“\r\n”;
    $headers.='内容类型:文本/html;字符集=iso-8859-1'。“\r\n”;
    $headers.='To:Somename'。“\r\n”;
    $headers.='Cc:'。$yourCopyMail。“\r\n”;//这是复印件
    //然后
    如果(邮件(…){
    回音“已发送”;
    }
    否则{
    标题(“位置:指向您的错误页面的url”);
    出口
    }
    

    如果要发送邮件副本,则需要为邮件添加适当的标题,如:

    
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'To: Somename <some_email@example.com>' . "\r\n";
    $headers .= 'Cc: '.$yourCopyMail . "\r\n"; // this is for copy
    //then
    if(mail(....)) {
      echo "sent";
    }
    else {
      header("Location: url_to_your_error_page");
      exit;
    }
    
    
    $headers='MIME版本:1.0'。“\r\n”;
    $headers.='内容类型:文本/html;字符集=iso-8859-1'。“\r\n”;
    $headers.='To:Somename'。“\r\n”;
    $headers.='Cc:'。$yourCopyMail。“\r\n”;//这是复印件
    //然后
    如果(邮件(…){
    回音“已发送”;
    }
    否则{
    标题(“位置:指向您的错误页面的url”);
    出口
    }
    

    关于你的第一个问题:

    在下一页提供有关如何向窗体中添加复选框并接收值的快速教程。在处理表单提交时,只需查看变量
    $\u POST[“checkboxname”]
    ,看看它是否设置为您给复选框的值(或者是否真的设置了)。如果是,则只需重复发送电子邮件的命令,将用户的电子邮件作为收件人

    在您的情况下,看起来应该是
    $send=mail($email,'messagefromyconatct表单',$content,$headers)


    我不知道如何回答你的第二个问题,因为“如果一切都糟糕透了”不是一个特别有意义的条件

    关于你的第一个问题:

    <?php
    $youremail  = "someonesemail@email.com";
    $yourname   = $_POST['yourname'];
    $email      = $_POST['email'];
    $location   = $_POST['location'];
    $textarea   = $_POST['textarea'];
    $ReceiveMail= $_POST['txtReceive'];
    
    if($ReceiveMail == "yes") {
        $content    = "";
        $headers    = "From: $email";
        @mail($email, 'Mail Notification', $content, $headers);
    }
        $headers    = "From: $email";
        $content = "Hello there! This is a message from your contact form.\r\n
        \r\n
        \r\n
        Name: $yourname\r\n
        \r\n
        E-mail: $email\r\n
        \r\n
        Location: $location\r\n
        \r\n
        Message: $textarea\r\n\r\n";
        $send = mail($youremail, 'Message from your conatct form', $content, $headers);
        if($send)    {
            header("location:thankyou.php");
            exit;
        }
        else {
            header("location:error.php");
            exit;
        }
    ?>
    
    在下一页提供有关如何向窗体中添加复选框并接收值的快速教程。在处理表单提交时,只需查看变量
    $\u POST[“checkboxname”]
    ,看看它是否设置为您给复选框的值(或者是否真的设置了)。如果是,则只需重复发送电子邮件的命令,将用户的电子邮件作为收件人

    在您的情况下,看起来应该是
    $send=mail($email,'messagefromyconatct表单',$content,$headers)

    我不知道如何回答你的第二个问题,因为“如果一切都糟糕透了”不是一个特别有意义的条件

    
    
    <?php
    $youremail  = "someonesemail@email.com";
    $yourname   = $_POST['yourname'];
    $email      = $_POST['email'];
    $location   = $_POST['location'];
    $textarea   = $_POST['textarea'];
    $ReceiveMail= $_POST['txtReceive'];
    
    if($ReceiveMail == "yes") {
        $content    = "";
        $headers    = "From: $email";
        @mail($email, 'Mail Notification', $content, $headers);
    }
        $headers    = "From: $email";
        $content = "Hello there! This is a message from your contact form.\r\n
        \r\n
        \r\n
        Name: $yourname\r\n
        \r\n
        E-mail: $email\r\n
        \r\n
        Location: $location\r\n
        \r\n
        Message: $textarea\r\n\r\n";
        $send = mail($youremail, 'Message from your conatct form', $content, $headers);
        if($send)    {
            header("location:thankyou.php");
            exit;
        }
        else {
            header("location:error.php");
            exit;
        }
    ?>
    
    我在表单中添加了一个复选框,并在服务器端检查了值。 试试这个。希望对您有所帮助

    
    
    我在表单中添加了一个复选框,并在服务器端检查了值。
    试试这个。希望能有所帮助

    谢谢Sudhir,我正在看其他的goto。。。我想不出来。我会转一圈谢谢汉克斯·苏希尔,我在看其他人。。。我想不出来。我可以试一试谢谢