html post的内容php接受不到
html代码<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>Bob'sAutoParts-C...
html代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bob's Auto Parts-Customer Feedback</title>
</head>
<body>
<h1>Customer Feedback</h1>
<p>please tel us what you think:</p>
<form action="processfeedback.php" method="post">
Your name:<br/>
<input type="text" name="name"><br/>
Your email address:<br/>
<input type="text" name="email"><br/>
Your feedback:<br/>
<textarea name="feedback" cols="30" rows="10"></textarea><br/>
<input type="submit" value="提交">
</form>
</body>
</html>
php部分:``````````````````````````````````````````````````````````````````````````````````````
<?php
$name=$_POST['name'];
$email=$_POST['email'];
$feedback=$_POST['feedback'];
$toaddress='272516522@qq.com';
$mailcontent='Customer name:'.$name."\n".'Customer Email:'.$email."\n"."feedback:\n".$feedback."\n";
$subject='Feedback from web site';
$fromaddress='From:webserver@example.com';
mail($toaddress, $subject, $mailcontent);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bob's Auto Parts-Feedback Submitted</title>
</head>
<body>
<h1>Feedback has been sent.</h1>
</body>
</html> 展开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bob's Auto Parts-Customer Feedback</title>
</head>
<body>
<h1>Customer Feedback</h1>
<p>please tel us what you think:</p>
<form action="processfeedback.php" method="post">
Your name:<br/>
<input type="text" name="name"><br/>
Your email address:<br/>
<input type="text" name="email"><br/>
Your feedback:<br/>
<textarea name="feedback" cols="30" rows="10"></textarea><br/>
<input type="submit" value="提交">
</form>
</body>
</html>
php部分:``````````````````````````````````````````````````````````````````````````````````````
<?php
$name=$_POST['name'];
$email=$_POST['email'];
$feedback=$_POST['feedback'];
$toaddress='272516522@qq.com';
$mailcontent='Customer name:'.$name."\n".'Customer Email:'.$email."\n"."feedback:\n".$feedback."\n";
$subject='Feedback from web site';
$fromaddress='From:webserver@example.com';
mail($toaddress, $subject, $mailcontent);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bob's Auto Parts-Feedback Submitted</title>
</head>
<body>
<h1>Feedback has been sent.</h1>
</body>
</html> 展开
展开全部
要得到post发送的数据必须是在通过submit按钮提交,或者通过Ajax提交之后。
打开页面显示错误,可以通过判断是否有post数据来解决问题,另外为了增加安全性,建议再加htmlspecialchars方法。
if($_POST){
$name=htmlspecialchars($_POST['name']);
$email=htmlspecialchars($_POST['mail']);
$feedback=htmlspecialchars($_POST['feedback']);
}
展开全部
首次访问,无POST值!
@$name=$_POST['name'];
@$email=$_POST['mail'];
@$feedback=$_POST['feedback'];
通过加@去除错误!
第二个问题,mail函数错误!
mail函数的具体介绍:http://www.w3school.com.cn/php/php_ref_mail.asp
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
先判断你的表单是否设置为“<form method="post">"
再者判断$_POST[""][""]是否书写正确,再输出。;
再者判断$_POST[""][""]是否书写正确,再输出。;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个,如果是最基本的表单提交 请查找下 POST 路径是否正确
上传文件 POST 需要在form标签设置一个值
上传文件 POST 需要在form标签设置一个值
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询