PHP send()突然停止工作

时间:2016-01-12 18:15:23

标签: php mysql

我发送电子邮件的PHP脚本突然停止工作,它一直都在工作,现在当我再次尝试它时,它显示了错误代码。我看到没有语法错误,我完全难过。

任何可以找出问题所在的人?

<?php
$namn = $_POST['namn'];
$epost = $_POST['epost'];
$tfn = $_POST['tfn'];
$msg = $_POST['msg'];
$from = 'B&P Contact';
$to = 'xxx@xxxxx.com';
$subject = 'Kontakt';

//message body
$body = "From: $name\n E-post: $epost\n Telefonnummer: $tfn\n Meddelande:\n $msg";
?>

<?php
//When send is clicked, execute function.
if ($_POST['send']) {
   if (mail ($to, $subject, $body, $from)) {
      echo '<p class="wtext" style="color:red;margin-left:25px;"> Message sent!</p>';
   }
 //error if somethings not working
   else {
      echo '<p class="wtext"> Something is wrong, try again.</p>';
   }
}
?>

我也有这个代码,但这与此无关,我尝试删除它等。此代码用于将每个msg存储在数据库中,然后打印出每个数据库中的帖子总数发送消息的时间。 (这仅适用于学校作业)。

<?php 
$conn = mysqli_connect('xxxxx', 'xxxxx', 'xxxx')
    or die('Could not establish connection to MySQL');
    $db_connected = mysqli_select_db($conn, 'xxxxx');
    //
    //
    $sql = "INSERT INTO Epostlist (namn, epost, tfn, msg) VALUES ('$namn', '$epost', '$tfn', '$msg')";
    //
    // Exikvera
    $status = mysqli_query($conn, $sql) or die (mysqli_error($conn));
    //
    //
    mysqli_close($conn);
?>

 <?php
      //Räkna meddelanden i databas
  $con=mysqli_connect("xxxx","xxxx","xxxxx","xxxxxx");
      // Check connection
      if (mysqli_connect_errno())
      {
       echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }
      //
      $sql="SELECT msg FROM Epostlist ORDER BY ID";
      //
      if ($result=mysqli_query($con,$sql))
      {
      // Return the number of rows in result set
      $rowcount=mysqli_num_rows($result);
      //
      echo "<p class='wtext'>We have been sent a total of $rowcount messages.\n</p>";
      // Free result set
      //
      mysqli_free_result($result);
      }
      //
      mysqli_close($con);
?>

上面的代码也适用于上面的代码。

*表格

<form method="post" action="send.php">
   Namn:<br><input type="text" name="namn" id="name"><br>
   E-post:<br><input type="text" name="epost" id="epost"><br>
   Telefonnummer:<br><input type="text" name="tfn" id="tfn"><br>
   Meddelande:<br><textarea name="msg" id="msg"></textarea><br>
   <input type="submit" name="send" value="Skicka" id="send"><br><br>
</form>

0 个答案:

没有答案