dpwh11290 2018-12-31 00:46
浏览 17

没有数据发送到mysql服务器?

No data was sended to mysql. Tryed without error message, im crashed end point.

No data goint to mysql server

I tryed figure out how it wont send but no luck at all. Not a code master sorry. Please help fix this error!

elseif ($inav == "feedbackreport")

{
echo '<div class="alert alert-success" role="alert">';
echo '<h4 class="alert-heading">Feedback report</h4>';
echo '<p>Have some feedback about my site or want contact?</p>';        
echo ' <hr>';       
echo '<p class="mb-0">Just fill required fields</p>';   
echo ' </div>'; 

{
echo '<form action="?inav=feedbackverify" method="post">';

echo '<p><strong><div style="padding:5px 10px;"><span style="font-size:14px; color:#428FF3;">Describe your feedback</strong><p><p>
      <textarea id="feedback" name="feedback" class="form-control" placeholder="Whats the feedback?" rows="3"></textarea>
      </div>';

echo '<strong><div style="padding:5px 10px;"><span style="font-size:14px; color:#428FF3;">Your e-mail</span></span></strong><p><p>
      <input type="email" name="mail" placeholder="Email" class="form-control">
      </div>';

$integer1 = rand(0,10);
$integer2 = rand(0,10);
$sum = $integer1 + $integer2;

echo '<input type="hidden" value="'.$sum.'" name="sum">';
echo '<div class="alert alert-primary" role="alert">
      SPAM-protection How much is <span style="color: #808080;"><strong>'.$integer1.' + '.$integer2.'</strong></span> ?
      </div>';

echo '<div style="padding:5px 10px;"><span style="font-size:14px; color:#428FF3;">
      <input type="number" name="spam" placeholder="Number Answer Only" class="form-control">
      </div>';

echo '<div style="padding:5px 10px;"><span style="font-size:14px; color:#428FF3;">
      <button type="submit" class="btn btn-secondary btn-sm">Send</button>
      </div>';

    }

    }

elseif ($inav == "feedbackverify")
{

$feedback = mysqli_real_escape_string($conn, $_POST['feedback']);
$mail = mysqli_real_escape_string($conn, $_POST['mail']);
$sum = mysqli_real_escape_string($conn, $_POST['sum']);
$spam = mysqli_real_escape_string($conn, $_POST['spam']);
$mailCheck = mailCheck($mail);
if($mailCheck==TRUE && $sum==$spam)
    {
    mysqli_query($conn, $query);
$query = "INSERT INTO feedbacks (feedback,mail) VALUES ('".$feedback."','".$mail."')";  
echo '<p style="text-align: center;"><span style="color:#008000;"><span style="font-size:18px;"><strong>Thank you for reporting, i will take a look ASAP!</strong></span></span></p> <p style="text-align: center;"><img src="img/smile_big.png" title="Smile more and enjoymy site!" /></p>';
    }
else
    {
echo '<p><div class="alert alert-danger" role="alert"><span style="color:#FF0000"><strong>Error: Wrong mail format OR wrong spam-protection! Go back and try it again.</strong></span></div>';
echo '<div style="padding:5px 10px;"><INPUT TYPE="button" class="btn btn-secondary btn-sm" VALUE="Go Back" onClick="history.go(-1);"></div>';
    }
}
  • 写回答

1条回答 默认 最新

  • dsmupo6631 2019-01-01 02:10
    关注

    You currently have this in your code:

    if($mailCheck==TRUE && $sum==$spam)
        {
        mysqli_query($conn, $query);
    $query = "INSERT INTO feedbacks (feedback,mail) VALUES ('".$feedback."','".$mail."')";  
    echo '[...]';
        }
    

    This is the wrong way around. You are trying to execute $query before it exists. mysqli_query() will execute immediately and will not wait for you to define the variable. In fact, this should trigger an "Undefined variable: query" warning if you have error reporting set up correctly.

    The correct way is to define $query first:

    if($mailCheck==TRUE && $sum==$spam)
        {
        $query = "INSERT INTO feedbacks (feedback,mail) VALUES ('".$feedback."','".$mail."')";  
        mysqli_query($conn, $query);
        echo '[...]';
        }
    

    If this still doesn't work, check whether the query executes properly:

    if($mailCheck==TRUE && $sum==$spam)
        {
        $query = "INSERT INTO feedbacks (feedback,mail) VALUES ('".$feedback."','".$mail."')";  
        if (!mysqli_query($conn, $query)) {
            echo mysqli_error($conn);
        }
        echo '[...]';
        }
    

    If that reports an error, let me know.

    评论

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用