Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.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处理文件没有';t工作_Php_Forms - Fatal编程技术网

我的PHP处理文件没有';t工作

我的PHP处理文件没有';t工作,php,forms,Php,Forms,我需要一点帮助。我创建了一个文件traitement.php来从我的表单中恢复数据,但当我单击“发送”按钮时,我没有收到任何消息(form sent…) 字段:姓名、姓氏、电子邮件和项目目标为必填项,其余为非必填项 我使用WAMP+sendmail,它被很好地配置为发送邮件。另一个PHP脚本可以工作 <?php header('Content-type: text/html; charset=utf-8'); if(isset($_POST) && isset(

我需要一点帮助。我创建了一个文件traitement.php来从我的表单中恢复数据,但当我单击“发送”按钮时,我没有收到任何消息(form sent…)

字段:姓名、姓氏、电子邮件和项目目标为必填项,其余为非必填项


我使用WAMP+sendmail,它被很好地配置为发送邮件。另一个PHP脚本可以工作

<?php

header('Content-type: text/html; charset=utf-8');

    if(isset($_POST) && isset($_POST['form2_prenom']) && isset($_POST['form2_nom']) && isset($_POST['form2_email']) && isset($_POST['form2_telephone']) && isset($_POST['form2_societe']) && isset($_POST['form2_url']) && isset($_POST['form2_secteur']) && isset($_POST['form2_projet']) && isset($_POST['form2_nature']) && isset($_POST['form2_objectif']) && isset($_POST['form2_cible']) && isset($_POST['form2_delai']) && isset($_POST['form2_budget']) && isset($_POST['form2_cahier']) && isset($_POST['form2_identite']) && isset($_POST['form2_souhaits']) && isset($_POST['form2_exemples']) && isset($_POST['form2_dev']) && isset($_POST['form2_services']) && isset($_POST['choix_contact']) && isset($_POST['choix_moment'])) {
        extract($_POST);
        if(!empty($form2_prenom) && !empty($form2_nom) && !empty($form2_email) && !empty($form2_projet) && !empty($form2_objectif)) {

            $to = 'xxxxx@gmail.com'; // My real email

            $subject = 'Contact from the site';

            $headers = 'MIME-Version: 1.0' . "\r\n";
            $headers .= 'Content-Type: text/html; charset=utf-8' . "\r\n";
            $headers .= 'From:' .$form2_prenom. " " .$form2_email. "\r\n";
            $headers .= 'Reply-To:'.$form2_email. "\r\n";

            $message = 'Surname : $form2_prenom \n';
            $message .= 'Name : $form2_nom \n';
            $message .= 'Email : $form2_email \n';
            $message .= 'Tel : $form2_telephone \n';
            $message .= 'Company : $form2_societe \n';
            $message .= 'URL : $form2_url \n';
            $message .= 'Sector : $form2_secteur \n';
            $message .= 'Project : $form2_projet \n';
            $message .= 'Nature : $form2_nature \n';
            $message .= 'Purpose : $form2_objectif \n';
            $message .= 'Target : $form2_cible \n';
            $message .= 'Deadline : $form2_delai \n';
            $message .= 'Budget : $form2_budget \n';
            $message .= 'Specifications : $form2_cahier \n';
            $message .= 'Identity : $form2_identite \n';
            $message .= 'Wishes : $form2_souhaits \n';
            $message .= 'Examples : $form2_exemples \n';
            $message .= 'Development : $form2_dev \n';
            $message .= 'Services : $form2_services \n';
            $message .= 'To contact : $choix_contact \n';
            $message .= 'The : $choix_moment \n';

            if(mail($to, $subject, $message, $headers)){
                echo "The form has been sent";
            } else {
                echo "The form has not been sent";
            }

        } else {
            echo "You have not filled in all the fields";
        }
    }
?>


从脚本发送电子邮件需要正确配置服务器。查看以了解更多信息。

首先按如下方式转换所有行:

$message = 'Prénom : $form2_prenom \n';
致:

或:


第二:使用phpMailer类发送邮件。访问:

请发布有关底层操作系统和项目设置的更多信息,可能是一种配置。好的,我更新了我的帖子:我使用WAMP+sendmail,它配置良好,可以发送邮件。另一个PHP脚本可以工作。正如Rahul所说,使用类似的方法来完成此操作-您的脚本容易受到标头注入攻击,并且可能会导致错误编码的消息,因为它没有进行过滤或格式化。电子邮件一点也不简单!嗨,谢谢。我将Wamp与sendmail一起使用,这是与另一个PHP文件一起使用的。我使用Wamp+sendmail,它配置良好,可以发送邮件。另一个PHP脚本可以工作。
$message = "Prénom : $form2_prenom \n";
$message = 'Prénom : '.$form2_prenom.' \n';