简体   繁体   English

信息提交后,表格就不会出现,信息也不会发送

[英]once the info is submited, the table not appearing and info not sent

if i click notify button , the message is sent but it is not sent as email, and also the returning page does not have the table again, i have echoed the message and it is there, but cant figure much out 如果我单击“通知”按钮,则会发送邮件,但不会将其作为电子邮件发送,并且返回页面也没有表格,我已经回显了该邮件,并且它在那里,但无法弄清楚

     <?php require_once("include/session.php");?>
    <?php require_once("include/dataconnect.php");?>
    <?php require_once("include/functions.php");?>
    <?php include("include/mheader.php");?>
   >
    <p>

        You can contact us so as to give you relevant numbers to speak to.Thank you.
    </p>
    <?php
    $submit = $_POST['Notify'];
    $message = mysql_real_escape_string(htmlentities(strip_tags($_POST['message'])));
    //echo "$message";
    //die();
    if('POST' === $_SERVER['REQUEST_METHOD']) 
    {
    if ($message)
    {
    //Get Email Address
        $emails = mysql_query("SELECT reusers.email FROM reusers INNER JOIN repplac ON reusers.username = repplac.Uname AND reusers.username = '{$_SESSION['username']}'")or die(mysql_error());
        //$emails = mysql_query("SELECT reusers.email FROM reusers INNER JOIN repplac ON reusers.username = repplac.Uname AND reusers.username = '".$_SESSION['username']."'")or die(mysql_error());
        $results = (mysql_fetch_assoc($emails)) or die(mysql_error());
        $email= $results['email'];
        //echo "$email";
        //die();
       if(mysql_num_rows($emails) == 0){
             exit("No email addresses found for user '{$_SESSION['username']}'");
        }
        $email = mysql_result($emails, 0);
        }
        $body = $message;
        $to = $email;
       $subject = "copy of your notification"; 
    $headers = "From: donotreply@rapsody.co.uk\r\n";  
    $headers  .= 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'Bcc:los@yahoo.ca' . "\r\n";
    mail($to,$subject,$body,$headers);
        }
    ?>
    <p>
    <form action='notification.php' method='Post' class='rl'>
        <div>
        <label for='message' class='fixedwidth'>Message</label>
        <textarea name="message" rows ="7" cols="40" id="message"></textarea>
        </div>

        <div class='buttonarea'>
                <p>
                <input type='submit' name='notify' value='Notify'>
                </p>
                </div>
                </p>
    </form>
    <?php include("include/footer.php");?>

using if ($message) {} is a bit tricky, if you want to know the $message contains some text, you would try with is_null or is_set 使用if ($message) {}有点棘手,如果您想知道$message包含一些文本,可以尝试使用is_nullis_set

Alos you may try mocing method before action in your form 您也可以尝试在表单中action之前action method

<form method='POST' action='notification.php' class='rl'>

One problem I can see is here: 我可以看到的一个问题在这里:

if ($message)
{
  ...
  $email = mysql_result($emails, 0);
}
$body = $message;
...

Now you are trying to send a message, even if $message evaluates to false and you don't have an address to send to. 现在,即使$message计算为false并且没有地址可发送,您仍在尝试发送消息。

You need to move the message sending section to within the if ($message) section. 您需要将消息发送部分移至if ($message)部分。

Edit: You are also overwriting your $email variable: 编辑:您还将覆盖$email变量:

$email= $results['email'];
//echo "$email";
//die();
if(mysql_num_rows($emails) == 0){
  exit("No email addresses found for user '{$_SESSION['username']}'");
}
$email = mysql_result($emails, 0); // get rid of this line

If your commented echo statement already gave the right result, you can get rid of the other, duplicate, assignment. 如果注释的echo语句已经给出正确的结果,则可以摆脱其他重复的赋值。

Apart from that it could be a server problem, mail being delivered to spam, etc. but that is not related to your code. 除此之外,这可能是服务器问题,邮件正被发送到垃圾邮件等,但这与您的代码无关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM