无法将我的表单数据提交到我的数据库中

时间:2015-02-19 17:29:20

标签: php mysql sql database apache

我无法让我的禁令系统适用于我的网站,我试了几个小时才能看到问题所在。我尝试了一切。甚至抬头看youTube。认为你们可以帮忙吗?这是数据库的提交代码。此外,我不想听到我使用“错误的PHP,应该使用Mysqli”我将更改它,直到下一个主要的PHP更新。

if (isset($_POST['post']))
{

 //get data
 $bannuser = $_POST['bannuser'];

 $TypeBan = $_POST['TypeBan'];
 $Reviewed = $_POST['Reviewed'];
 $ModNote = $_POST['ModNote'];
 $Reason = $_POST['Reason'];
 $OffenItem = $_POST['OffenItem'];
 $BanLengthMssg = $_POST['BanLengthMssg'];
 $ReleaseMssg = $_POST['ReleaseMssg'];
 $AppealMssg = $_POST['AppealMssg'];



 //Connect To The Database
 $connect = mysql_connect("####","####","####");
 mysql_select_db("####");

 $namecheck = mysql_query("SELECT bannuser FROM banned WHERE bannuser='$bannuser'");
 $count = mysql_num_rows($namecheck);

 if($count!=0)
 {
    die("This User Is Already Banned! <a href='home.php'>[Home]</a>");
 }

 //check for existance
 if ($bannuser)
 {
    if(strlen($bannuser)>25||strlen($bannuser)<6)
        {
            echo "<b>Length Of Username Is Must Be Between 6 and 25 Characters Long!</b>";
        }
        else
            {
                $queryreg = mysql_query("INSERT INTO banned (bannuser,TypeBan,Reviewed,ModNote,Reason,OffenItem,BanLengthMssg,ReleaseMssg,AppealMssg) VALUES ('$bannuser','$TypeBan','$Reviewed','$ModNote','$Reason','$OffenItem','$BanLengthMssg','$ReleaseMssg','$AppealMssg')");

                die ("<b>The Moderation Report Has Been Submitted! The User Is Now Banned!</b> <b><a href='home.php'>[Home]</a></b>");
            }


 }
 else
 {
    echo 'Please enter a Username';
 }
}

html on botton .....在编辑这篇文章时,表格元素被抓到了这里 - &gt;                用户名:           

      <div align="left">TypeBan(<i>Remember if you set a ban date make sure the TypeBan is the same as the Ban Length Message</i>):
      <select name="TypeBan">
      <option value="Reminder">Reminder</option>
      <option value="Warning">Warning</option>
      <option value="Banned for 1 Day">Banned for 1 Day</option>
      <option value="Banned for 3 Days">Banned for 3 Days</option>
      <option value="Banned for 7 Days">Banned for 7 Days</option>
      <option value="Banned for 14 Days">Banned for 14 Days</option>
      <option value="Account Deleted">Account Deleted</option>
      <option value="Account Under Admisitrative Review">Account Under Admisitrative Review</option>
      </select></div><p>


      Reviewed:
      <input type='text' readonly='readonly' name='Reviewed' value='<?php echo date("Y-m-d"); ?>'/><p>

      Moderator Note:
      <select name="ModNote">
      <option value="Don't create accounts just to harass users or break rules.">Don't create accounts just to harass users or break rules.</option>
      <option value="Don't say inappropriate things on PyroStudio.">Don't say inappropriate things on PyroStudio.</option>
      <option value="Don't lie about being an admin.">Don't lie about being an admin.</option>
      <option value="Don't exceed Account Spending Limit.">Don't exceed Account Spending Limit.</option>
      <option value="Don't harass/threaten/abuse/offend our employees or members.">Don't harass/threaten/abuse/offend our employees or members.</option>
      <option value="Don't provide false or inaccurate information.">Don't provide false or inaccurate information.</option>
      <option value="Don't use Services in any manner restricted by or inconsistent with the Agreement and Policies.">Don't use Services in any manner restricted by or inconsistent with the Agreement and Policies</option>
      <option value="Don't provide false, inaccurate, dated, or unveriable identification or credit information.">Don't provide false, inaccurate, dated, or unveriable identification or credit information.</option>
      </select><p>

      Reason:
      <select name="Reason">
      <option value="Inappropriate">Inappropriate</option>
      <option value="Adult Content">Adult Content</option>
      <option value="Profanity">Profanity</option>
      <option value="Harassment">Harassment</option>
      <option value="Suspicious Activity">Suspicious Activity</option>
      <option value="">N/A</option>
      </select><p>

      Offensive Item:
      <input type='text' name='OffenItem' value=''/><p>

      Ban Length Message:
      <select name="BanLengthMssg">
      <option value="This is just a Reminder">This is just a Reminder</option>
      <option value="This is just a Warning">This is just a Warning</option>
      <option value="Your account has been disabled for 1 day">Your account has been disabled for 1 day</option>
      <option value="Your account has been disabled for 3 days">Your account has been disabled for 3 days</option>
      <option value="Your account has been disabled for 7 days">Your account has been disabled for 7 days</option>
      <option value="Your account has been disabled for 14 days">Your account has been disabled for 14 days</option>
      <option value="Your Account Has Been Terminated">Your Account Has Been Terminated</option>
      <option value="Your account is Temporarily Frozen for Suspicious Activity and will be reactivated when the Administrators are done reviewing your Account.">Your account is Temporarily Frozen for Suspicious Activity and will be reactivated when the Administrators are done reviewing your Account.</option>
      </select><p>

      Release Message(You may re-activate it after Y-m-d):
      <input type='text' name='ReleaseMssg' value=''/><p>

      Appeal Mssg(Select the Blank space if account is deleted):
      <select name="AppealMssg">
      <option value="If you wish to appeal, please send an email to info.pyrostudio@gmail.com or just wait until ban date is over.">If you to appeal, please send an email to info.pyrostudio@gmail.com or just wait until ban date is over.</option>
      <option value="Your Account is under Administrative review and may or may not be reactivated depending on the infraction.">(Frozen/Suspended Account)</option>
      <option value="">No Appeal For `Account Deleted` members</option>
      </select><p>

      <input type="submit" name="post" value="Submit Report" /> | <a href="home.php">[ Home ]</a>

</form></div>

2 个答案:

答案 0 :(得分:0)

尝试在else部分内打印一些内容并注释掉查询执行以确认,它至少进入其他部分&#39;否则&#39;部分

否则             {
echo&#34;进入其他条件&#34;;

// $ queryreg = mysql_query(&#34; INSERT INTO ...&#34;);
            }

如果它正在进入。下一步是通过phpmyadmin或MySQL控制台直接执行查询以仔细检查查询。有时我经历过列名中的后引号符号(`)也起作用

"INSERT INTO banned (`bannuser`,`TypeBan`,`Reviewed`,`ModNote`,`Reason`,`OffenItem`,`BanLengthMssg`,`ReleaseMssg`,`AppealMssg`) VALUES ('$bannuser','$TypeBan','$Reviewed','$ModNote','$Reason','$OffenItem','$BanLengthMssg','$ReleaseMssg','$AppealMssg')");

答案 1 :(得分:0)

首先尝试在浏览器中打印查询以查看值内部的内容,从浏览器中复制并通过phpmyadmin执行它,如果获取数据库中的值,则通过php代码执行它

else { 
$queryreg = "INSERT INTO banned (bannuser,TypeBan,Reviewed,ModNote,Reason,OffenItem,BanLengthMssg,ReleaseMssg,AppealMssg) VALUES ('$bannuser','$TypeBan','$Reviewed','$ModNote','$Reason','$OffenItem','$BanLengthMssg','$ReleaseMssg','$AppealMssg')";

echo $queryreg; 

mysql_query($queryreg); 
}