gpt4 book ai didi

php - 联系表未发送

转载 作者:行者123 更新时间:2023-11-28 03:40:15 24 4
gpt4 key购买 nike

我让它工作了一分钟,但我不确定我做了什么来阻止它工作。提交时它仍然带我到另一个页面,但我的电子邮件完全没有任何事件。

HTML

<form id="contact_form" action="sendemail.php" method="post">
<p><label>Name:<br />
<input type="text" name="name" class="textfield" value="" />
</label></p>

<p><label>Email: <br />
<input type="text" name="email" class="textfield" value="" />
</label></p>

<p><label>Phone Number: <br />
<input type="text" name="phone" class="textfield" value="" />
</label></p>

<p><label>Detail: <br />
<textarea name="detail" class="textarea" cols="45" rows="5"></textarea>
</label></p>

<p><input type="submit" name="submit" class="button" value="Submit" /></p>
</form>

PHP

<?php 
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$phone = $_REQUEST['phone'];
$detail = $_REQUEST['detail'];

$message = "Name: $name\nEmail: $email\nPhone Number: $phone\nDetail: $detail" ;

mail( "myemail@gmail.com", "You have recieved a message", "Information Requested:\n\n$message", "From: $email") ;

header( "location: http://mywebsite.com/thanks.html" );

?>

最佳答案

您应该定义标题并做一些改进,尝试使用此代码:

// As you know that you form uses POST method, you can use $_POST instead of $_REQUEST
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$detail = $_POST['detail'];

// Headers
$headers = "From: =?utf-8?B?".base64_encode ('Sender Name')."?= <sender@email.com>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=utf-8\r\n";

// As the content is HTML, you shoud use <br /> instead of \n to break line
$message = "Name: $name<br />Email: $email<br />Phone Number: $phone<br />Detail: $detail" ;

// Trying to send the message
if ( mail('to@email.com', "=?utf-8?B?".base64_encode('Message subject')."?=", $message, $headers) )
header( "location: http://mywebsite.com/thanks.html" );
else
echo 'Message fail';

关于php - 联系表未发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11496325/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com