这是一个小问题,我相信答案很简单,但也许我看不到树木:
我有一个显示数据的表格;要求用户编辑数据,然后更新数据并发送包含更新数据的电子邮件。电子邮件到达,但显示标题不显示数据。
我做错了什么?
电子邮件中显示的文字:
名称:
电子邮件:
电话:
php代码:
$email_to = 'someone@here.com';
$name=$row['name'];
$email=$row['email'];
$phone=$row['mobtel'];
$email_subject = 'Feedback from website';
$headers = 'From: someone@there.com\r\n';
someone$message='Name: ' .$name. "\r\n". 'Email: ' .$email. "\r\n". 'Phone: ' .$phone;
$sent = mail($email_to, $email_subject, $message, $headers);
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
这是上面的PHP代码:
mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($dbname) or die("Unable to connect: " . mysql_error());
if (isset($_GET['view']))
{
$user = sanitizeString($_GET['view']);
$data = "SELECT * FROM names WHERE id='$user'";
$result=mysql_query($data) or die(mysql_error());
while($row=mysql_fetch_array($result)){
?>
<caption>Personal Record</caption>
<tr>
<th>ID</th>
<td><?php
echo $row['id'];
?></td>
</tr>
<tr>
<th>Name</th>
<td><?php
echo $row['name'];
?></td>
</tr>
<tr>
<th>E-Mail</th>
<td><?php
echo $row['email'];
?></td>
</tr>
<tr>
<th>Main Telephone</th>
<td><?php
echo $row['maintel'];
?></td>
</tr>
<tr>
<th>Mobile Telephone</th>
<td><?php
echo $row['mobtel'];
?></td>
</tr>
<tr>
<th>Organisation</th>
<td><?php
echo $row['organisation'];
?></td>
</tr>
<tr>
<th>Group Leader</th>
<td><?php
echo $row['group_leader'];
?></td>
</tr>
<tr>
<th>Supervisor</th>
<td><?php
echo $row['supervisor'];
?></td>
</tr>
<tr>
<th>Volunteer</th>
<td><?php
echo $row['volunteer'];
?></td>
</tr>
<tr>
<th>Assessor</th>
<td><?php
echo $row['assessor'];
}
}
?></td>
</tr>
</table>
<br />
<form method="post" action="update.php">
<input name="Submit1" type="submit" value="Edit" style="width: 67px" /></form>
<p> </p>
答案 0 :(得分:2)
someone$message
应该是$message
答案 1 :(得分:1)
您忘了在发送的内容中添加某人$;
答案 2 :(得分:0)
首先将此someone$message
更改为$message
,然后执行代码。原因可能是您的数组$row
似乎没有任何价值。或者检查$row[]
使用print_r($row)
; : - )