-2

这是一个小问题,我相信答案很简单,但也许我看不到树木的木材:

我有一个显示数据的表格;用户被要求编辑数据,进而更新数据库并发送包含更新数据的电子邮件。电子邮件到达,但虽然显示标题但未显示数据。

我究竟做错了什么?

电子邮件中显示的文本:

姓名:
电子邮件:
电话:

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>&nbsp;</p>
4

3 回答 3

2

someone$message应该是$message

于 2012-04-26T11:07:19.537 回答
1

您忘记在发送的内容中添加某人$消息;

于 2012-04-26T11:06:15.083 回答
0

首先将其更改someone$message$message然后执行代码。原因可能是您的数组$row似乎没有任何价值。或检查$row[]使用print_r($row);:-)

于 2012-04-26T11:12:03.387 回答