Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我需要通过什么发送输入类型。请按“提交”按钮_Php_Email_Submit - Fatal编程技术网

Php 我需要通过什么发送输入类型。请按“提交”按钮

Php 我需要通过什么发送输入类型。请按“提交”按钮,php,email,submit,Php,Email,Submit,我想做一个php代码,提交一些信息发送到我的私人电子邮件地址。我正在寻找的代码是通过电子邮件发送并提交这是我的代码: "<div class="form_settings"> <p><span>Navn</span><input class="contact" type="text" name="your_name" value="" /></p> <p><s

我想做一个php代码,提交一些信息发送到我的私人电子邮件地址。我正在寻找的代码是通过电子邮件发送并提交这是我的代码:

"<div class="form_settings">
            <p><span>Navn</span><input class="contact" type="text" name="your_name" value="" /></p>
            <p><span>Email Addresse</span><input class="contact" type="text" name="your_email" value="" /></p>
            <p><span>Besked</span><textarea class="contact textarea" rows="5" cols="50" name="your_message"></textarea></p>
            <p style="padding-top: 15px"><span>&nbsp;</span><input class="submit" type="submit" name="contact_submitted" value="send"></p>
          </div>"
”
纳文

电子邮件地址

包围

"
在表单操作指向的页面上插入此代码(例如,如果有,则应将此代码放在send_message.php上:

<?php
    if (isset($_POST['your_name']) && isset($_POST['your_email']) && isset($_POST['your_message'])) {
        if (!empty($_POST['your_name']) && !empty($_POST['your_email']) && isset($_POST['your_message'])) {
            $to = "INSERT THE EMAIL ADDRESS YOU WANT TO SEND TO";
            $subject = "SUBJECT";
            $name = $_POST['your_name'];
            $email = $_POST['your_email'];
            $message = "$name sent you a message:"
            $message .= "<br><br>" . $_POST['your_message'];
            $headers = "MIME-Version: 1.0" . "\r\n";
            $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
            $headers .= 'From: ' . $email . "\r\n";

            if (mail($to,$subject,$message,$headers)) {
                header('Location: confirmation.php');
            };
        };
    };
?>


另外,学习PHP需要时间,但很值得,youtube有很多好的视频。

我对PHP有点陌生,但很高兴能得到一些帮助。感谢您抽出时间回答我的问题,如果我要提醒用户邮件已发送,我能做些什么?您可以使用不同的页面(例如使用action=“confirmation.PHP”在元素中。在该页面上,您可以添加一条消息,表示已成功发送。或者,您可以将其更改为:mail($to,$subject,$message,$headers);改为:if(mail($to,$subject,$message,$headers)){header('Location:confirmation.php');};这比我写的另一个更好,因为它只在邮件成功发送时重定向(如果邮件有效,则返回true)。我将编辑答案以显示这一点。