PHP表单烧制空白 [英] PHP form firing blanks
本文介绍了PHP表单烧制空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不确定问题出在哪里,想知道是否有人愿意帮忙。
p>这里是HTML
< div class =form>
< form method =postaction =send_contact.php>
< div class =form_row>
< label>您的名称:< / label>
< input type =textname =nameclass =main_input/>
< / div>
< div class =form_row>
< label>您的电子邮件地址:< / label>
< input type =textname =emailclass =main_input/>
< / div>
< div class =form_row>
< label>查询类型:< / label>
< input type =textname =inquiryclass =main_input/>
< / div>
< div class =form_row>
< label>您的讯息:< / label>
< / div>
< div class =form_row>
< input type =submitclass =submitvalue =Submit>
< / div>
< / div>
< / form>
< / div>
这里是PHP
<?php
$ subject =$ inquiry;
$ message =$ message;
$ mail_from =$ email;
$ header =from:$ name< $ mail_from>;
//输入您的电子邮件地址
$ to ='inquiries@openrhythmnetwork.com';
$ send_contact =邮件($ to,$ subject,$ message,$ header);
//检查是否有信息发送到您的电子邮箱
//显示信息我们收到您的信息
if($ send_contact){
echo我们已经收到您的联系信息;
}
else {
echoERROR;
}
?>
字面上,我收到的是一封空白的电子邮件,没有主题标题...
解决方案
以下已经过测试并在我的服务器上运行。 PHP版本5.4
PHP(send_contact.php)
< ?php
$ name = $ _POST ['name'];
$ subject = $ _POST ['inquiry'];
$ message = $ _POST ['message'];
$ mail_from = $ _POST ['email'];
$ header =From:$ name< $ mail_from>;
//输入您的电子邮件地址
$ to ='email@example.com'; //改为您的电子邮件地址
$ send_contact =邮件($ to,$ subject,$ message,$ header);
//检查是否有信息发送到您的电子邮件
//显示信息我们已收到您的信息
if($ send_contact){
echo我们已收到您的联系信息;
}
else {
echoERROR;
}
?>
HTML表单:
< div class =form>
< form method =postaction =send_contact.php>
< div class =form_row>
< label>您的名称:< / label>
< input type =textname =nameclass =main_input/>
< / div>
< div class =form_row>
< label>您的电子邮件地址:< / label>
< input type =textname =emailclass =main_input/>
< / div>
< div class =form_row>
< label>查询类型:< / label>
< input type =textname =inquiryclass =main_input/>
< / div>
< div class =form_row>
< label>您的讯息:< / label>
< / div>
< div class =form_row>
< input type =submitclass =submitvalue =Submit>
< / div>
< / div>
< / form>
< / div>
My PHP form is sending me blank emails.
I'm not sure where the issue is and wondered if anyone would be kind enough to help out.
Here's the HTML
<div class="form">
<form method="post" action="send_contact.php">
<div class="form_row">
<label>Your Name:</label>
<input type="text" name="name" class="main_input" />
</div>
<div class="form_row">
<label>Your Email:</label>
<input type="text" name="email" class="main_input" />
</div>
<div class="form_row">
<label>Type of Inquiry:</label>
<input type="text" name="inquiry" class="main_input" />
</div>
<div class="form_row">
<label>Your Message:</label>
<textarea name="message" class="main_textarea"></textarea>
</div>
<div class="form_row">
<input type="submit" class="submit" value="Submit" >
</div>
</div>
</form>
</div>
Here's the PHP
<?php
$subject = "$inquiry";
$message = "$message";
$mail_from = "$email";
$header = "from: $name <$mail_from>";
// Enter your email address
$to ='inquiries@openrhythmnetwork.com';
$send_contact = mail($to,$subject,$message,$header);
// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>
Literally, all I'm receiving is a blank email with no subject heading...
解决方案
The following has been tested and working on my server. PHP Version 5.4
PHP (send_contact.php)
<?php
$name = $_POST['name'];
$subject = $_POST['inquiry'];
$message = $_POST['message'];
$mail_from = $_POST['email'];
$header = "From: $name <$mail_from>";
// Enter your email address
$to ='email@example.com'; // change to your Email address
$send_contact = mail($to,$subject,$message,$header);
// Check, if message sent to your email
// display message "We've received your information"
if($send_contact){
echo "We've received your contact information";
}
else {
echo "ERROR";
}
?>
HTML form:
<div class="form">
<form method="post" action="send_contact.php">
<div class="form_row">
<label>Your Name:</label>
<input type="text" name="name" class="main_input" />
</div>
<div class="form_row">
<label>Your Email:</label>
<input type="text" name="email" class="main_input" />
</div>
<div class="form_row">
<label>Type of Inquiry:</label>
<input type="text" name="inquiry" class="main_input" />
</div>
<div class="form_row">
<label>Your Message:</label>
<textarea name="message" class="main_textarea"></textarea>
</div>
<div class="form_row">
<input type="submit" class="submit" value="Submit" >
</div>
</div>
</form>
</div>
这篇关于PHP表单烧制空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文