Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.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/3/html/80.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/8/file/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 html联系人表单不支持';行不通_Php_Html_Forms - Fatal编程技术网

Php html联系人表单不支持';行不通

Php html联系人表单不支持';行不通,php,html,forms,Php,Html,Forms,我在我的网页上有一个联系方式,所以我通过电子邮件给我发送消息,但它不起作用 我试图通过使用GET模式上的PHP代码和手动参数发送消息 <a href="contactpage.php?name=name&email=em&message=men">send</a> 而且它是有效的,所以可能错误在HTML代码上 HTML代码: <form id="contactForm" class="contact-form" name="formulario

我在我的网页上有一个联系方式,所以我通过电子邮件给我发送消息,但它不起作用

我试图通过使用GET模式上的PHP代码和手动参数发送消息

<a href="contactpage.php?name=name&email=em&message=men">send</a>

而且它是有效的,所以可能错误在HTML代码上

HTML代码:

<form id="contactForm" class="contact-form" name="formulario" method="post" action="contactpage.php">
    <div class="form-group form-icon-group">
        <input class="form-control" name="name" placeholder="Nombre" type="text" required/>
        <i class="fa fa-user"></i>
    </div>
    <div class="form-group form-icon-group">
        <input class="form-control" name="mail" placeholder="Email" type="text" required/>
        <i class="fa fa-envelope"></i>
    </div>
    <div class="form-group form-icon-group">
        <textarea class="form-control" name="mes" placeholder="Mensaje" rows="10" required></textarea>
        <i class="fa fa-pencil"></i>
    </div>
    <div class="text-center">
    <input type="submit" name="submit" value="Envía tu solicitud" class="btn btn-primary">
    </div>
</form>

以及PHP代码:

<?php
$nombre = $_POST['name'];
$email = $_POST['mail'];
$mensaje = $_POST['mes'];

$header = 'From:'. $email."\r\n";
$header.="X-Mailer: PHP/". phpversion(). "\r\n";
$header .= "Mime-Version: 1.0 \r\n";
$header .= "Content-Type: text/plain";

$mensaje = "Este mensaje fue enviado por " . $nombre . ", con email " . $email . " \r\n"; 
$mensaje .= "Su e-mail es: " . $email . " \r\n";
$mensaje .= "Mensaje: " . $_POST['mes'] . " \r\n";
$mensaje .= "Enviado el " . date('d/m/Y', time());

$para = 'myemail@email.com';
$asunto = 'Contacto desde la web';

$bool = mail($para, $asunto, utf8_decode($mensaje), $header);

if($bool){
    echo "Mensaje enviado";
}else{
    echo "Mensaje no enviado";
}
?>

谢谢大家!

$to      = 'email@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);


谢谢,但正如我所说,如果我使用GET模式,我的邮件功能会工作,因此问题不在于邮件功能上的参数。这也适用于post方法,您也可以使用phpmailer发送邮件谢谢,但正如我所说,如果我使用GET模式,我的邮件功能会工作,所以问题不在于邮件函数的参数。这也适用于post方法,您还可以使用phpmailer发送邮件