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

时间:2022-09-22 16:03:46

I can't get my ban system to work for my website and I tried for a few hours to see what the issue was. I tried everything. Even looked up on youTube. Think you guys can help? Here is the submit code for the database. Also, i dont want to hear that i'm using "Bad PHP and should use Mysqli" I will change it until the next major php update.

我不能让我的禁令系统适用于我的网站,我试了几个小时才能看到问题所在。我尝试了一切。甚至抬头看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..... Form element got caught here while editing this post -> Username:

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

      <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 个解决方案

#1


0  

Try to print something inside the else part and comment out the query execution to confirm that, it is at least going inside 'else' part

尝试在else部分内部打印一些东西并注释掉查询执行以确认它,它至少会进入'else'部分

else {
echo "Entering in else condition";

else {echo“进入其他条件”;

// $queryreg = mysql_query("INSERT INTO ...");
}

// $ queryreg = mysql_query(“INSERT INTO ...”); }

If it is entering. Next step would be to directly execute the query through phpmyadmin or MySQL console to double check the query. Sometimes I experienced that the back quote symbol (`) in column names also plays a role

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

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

#2


0  

Try to print the query in your browser first to see what is inside the values, copy that from browser and execute it via phpmyadmin and if you get the values in database, then execute it through php code

首先尝试在浏览器中打印查询以查看值内部的内容,从浏览器中复制并通过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); 
}

#1


0  

Try to print something inside the else part and comment out the query execution to confirm that, it is at least going inside 'else' part

尝试在else部分内部打印一些东西并注释掉查询执行以确认它,它至少会进入'else'部分

else {
echo "Entering in else condition";

else {echo“进入其他条件”;

// $queryreg = mysql_query("INSERT INTO ...");
}

// $ queryreg = mysql_query(“INSERT INTO ...”); }

If it is entering. Next step would be to directly execute the query through phpmyadmin or MySQL console to double check the query. Sometimes I experienced that the back quote symbol (`) in column names also plays a role

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

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

#2


0  

Try to print the query in your browser first to see what is inside the values, copy that from browser and execute it via phpmyadmin and if you get the values in database, then execute it through php code

首先尝试在浏览器中打印查询以查看值内部的内容,从浏览器中复制并通过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); 
}