从以前的php页面上的查询发送电子邮件

时间:2013-09-27 18:08:03

标签: php mysql email

请原谅我,但我觉得我的技能水平太深了: 数据库连接在include:

中设置

以下是代码:

<html>
  <body>
      <?php
      include "inc.php";
      //print_r ($_POST);


      //if "email" is filled out, send email
      if (isset($_POST['email']))

      {
          //send email
          While($row=mysql_fetch_array($querymail))
          {
              $to= $row['email'];
              $subject = $_REQUEST['subject'] ;
              $message = $_REQUEST['message'] ;
              $email= 'stats@my email.com';
              mail($to, $subject,
              $message, "From:" . $email);
              echo "email sent to ".$to;
          }
      }
      else
      //if "email" is not filled out, display the form
      {

          $Pnum=implode(',',$_POST['checkemail']);
          $querymail=mysql_query("select sp.email_address as email from stats_player sp where sp.player_num IN ($Pnum)");
          While($row=mysql_fetch_array($querymail))
          {
              echo "<table>";
              echo "<tr><td>".$row['email']."</tr.</td>";
          } 
          echo "<form method='post' action=''>

          Subject: <input name='subject' type='text'><br>
          Message:<br>
          <textarea name='message' rows='15' cols='40'>
          </textarea><br>
          <input type='submit'>
          </form>";
      }
  ?>
  </body>
</html>

当我允许print_r ($_POST);时,我按预期显示所有的player_nums。

页面打开时会显示正确的电子邮件列表(此表将消失,仅用于验证数据) 我收到了表格。

当我点击表单上的“提交”按钮时,我收到错误。

Warning: implode() [function.implode]: Invalid arguments passed in /home..../results/admin/emailall.php on line 31

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home..../results/admin/emailall.php on line 33

我认为,因为我将这个表单重新提交给自己,所以它正在清除我在初始查询中所拥有的内容。我以为我用isset绕过了那个,但我可能(可能是)错了。

(注意我在粘贴时删除了一些空行,因此错误行不对应)

0 个答案:

没有答案