BASIC PHP - MYSQL查询 - 表单不会提交,只需刷新

时间:2016-12-22 02:10:13

标签: javascript php html mysql ajax

我正在设计一个在线角色扮演游戏,(大佬主题)...... 我已经在Hit-list页面上工作了一段时间,但无论我尝试多少,我仍然无法理解这一点...

基本上我使用的form根本不会提交和更新database,只是在提交时刷新没有任何错误消息或任何内容,我会感激一些帮助这个,因为它现在开始绞尽脑汁......

我将在下面发布我的页面代码,这样你就可以得到这里发生的事情。 (还会链接到我网站上的文本文件,其中包含PHP & SQL & & Javascript & HTML代码的整页......

Click here for the link to the pages full code including HTML & Form...

<?php

///// START OF DEFAULTS /////

session_start();
include "include/connect.php";
include "include/require.php";
include_once("include/time.php");
logincheck();
$username=$_SESSION['username'];
$dateetime = gmdate('Y-m-d H:i:s',time()+60*60);
$fetch=mysql_fetch_object(mysql_query("SELECT * FROM user_info WHERE username='$username'"));
$view=$_GET['view'];
$select=$_POST['select'];

///// END OF DEFAULTS /////

?>

<?php

///// START OF HITLISTING USERS /////

if ($_POST['submit']){
    $target=addslashes(strip_tags($_POST['target'])); 
    $reward=addslashes(strip_tags($_POST['reward']));
    $reason=addslashes(strip_tags($_POST['reason']));
    $total_cost=intval(strip_tags($_POST['total_cost']));
    if ($select == "1"){
        if ($total_cost > "0"){
            if ($total_cost == 0 || !$total_cost || ereg('[^0-9]',$total_cost)){
                print "<table border='0' bordercolor='black' align='center' cellpadding='2' cellspacing='0'>
    <tr><td class='notice' align='center'><font color='#CAO300'>You have entered an invalid value!</td>
        </tr>
        </table><br>";
            }elseif ($total_cost != 0 && $total_cost && !ereg('[^0-9]',$total_cost)){
                if ($total_cost > $fetch->money){
                    echo "<table border='0' bordercolor='black' align='center' cellpadding='2' cellspacing='0'>
    <tr><td class='notice' align='center'><font color='#CAO300'>You do not have money to payout that reward!</td>
        </tr>
        </table><br>";
                }elseif ($total_cost <= $fetch->money){
                    $user_loose = $fetch->money - $total_cost;
                    $bank_add = $total_cost;
                    mysql_query("UPDATE user_info SET money=money-$total_cost WHERE username='$username'");
                    mysql_query("UPDATE hitlist_first SET reward=reward+$reward && hits=hits+1 && buy_off=buy_off+$total_cost WHERE target='$target'");
                    mysql_query("INSERT INTO `hitlist_second` ( `id` , `posted_by` , `anonymous` , `reason` , `reward` , `target` ) 
    VALUES ('', '$username', 'No', '$reason', '$reward', '$target')");
                    echo "<table border='0' bordercolor='black' align='center' cellpadding='2' cellspacing='0'>
    <tr><td class='notice' align='center'><font color='#2FB600'>You have successfully Hitlisted $target!</td>
        </tr>
        </table><br>";
                }
            }
        }
    }
}elseif ($select == "2"){
    if ($total_cost > "0"){
        if ($total_cost == 0 || !$total_cost || ereg('[^0-9]',$total_cost)){
            print "<table border='0' bordercolor='black' align='center' cellpadding='2' cellspacing='0'>
    <tr><td class='notice' align='center'><font color='#CAO300'>You have entered an invalid value!</td>
        </tr>
        </table><br>";
        }elseif ($total_cost != 0 || $total_cost || !ereg('[^0-9]',$total_cost)){
            if ($total_cost > $fetch->money){ echo "<table border='0' bordercolor='black' align='center' cellpadding='2' cellspacing='0'>
    <tr><td class='notice' align='center'><font color='#CAO300'>You do not have money to payout that reward!</td>
        </tr>
        </table><br>"; }elseif ($total_cost <= $fetch->money){
                $user_loose = $fetch->money - $total_cost;
                $bank_add = $total_cost;
                mysql_query("UPDATE user_info SET money=money-$total_cost WHERE username='$username'");
                mysql_query("UPDATE hitlist_first SET reward=reward+$reward && hits=hits+1 && buy_off=buy_off+$total_cost WHERE target='$target'");
                mysql_query("INSERT INTO `hitlist_second` ( `id` , `posted_by` , `anonymous` , `reason` , `reward` , `target` ) 
    VALUES ('', '$username', 'Yes', '$reason', '$reward', '$target')");
                echo "<table border='0' bordercolor='black' align='center' cellpadding='2' cellspacing='0'>
    <tr><td class='notice' align='center'><font color='#2FB600'>You have successfully Hitlisted $target!</td>
        </tr>
        </table><br>";
            }
        }
    }
}

///// END OF HITLISTING USERS /////

?>

1 个答案:

答案 0 :(得分:0)

你有:<input type="hidden" name="select" id="select" value="0">
所以你的变量$ select应为“0”
您只有if($select == "1")if($select == "2")
没有if($select == "0")这就是它没有做任何事情的原因