php 菜鸟中的极品

来源:百度知道 编辑:UC知道 时间:2024/06/08 05:59:32
<?php
//创建短期变量名称,
$name=$_POST['name'];
$email =$_POST['email'];
$feedback =$_POST['feedback'];

$roaddress = 'feedback@example.com';
$subject = 'Feedback from web site';
$mailcontent = 'Customer name:'.$name."\n"
.'Customer email:'.$email."\n"
."Customer comments: \n".$feedback."\n";
$fromaddress = 'From: webserver@example.com';

mail($roaddress, $subject, $mailcontent, $fromaddress);
?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>我的页面反馈意见表。</title>
</head>

<body>
<h1>有意见你就说</h1>
<p>你的间意见以发送,</p>
</body>
</html>

报错如下:

Notice: Undefined in

Notice: Undefined index: name in D:\www\php4\processfeedback.php on line 3

Notice: Undefined index: email in D:\www\php4\processfeedback.php on line 4

Notice: Undefined index: feedback in D:\www\php4\processfeedback.php on line 5

这些错误是因为你的html页面没有向php页面提交post内容。

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\www\php4\processfeedback.php on line 14

这个错误是因为你本地没有开smtp服务或者php配置文件php.ini中没有正确配置。