Note that there are some explanatory texts on larger screens.

plurals
  1. POCondition not working as expected
    primarykey
    data
    text
    <p>I have been writing a script for my online game server, to fetch the user name from the db and check for its level.</p> <p>The problem is that the code doesn't check for the level so any one at any level can vote and abuse my voting system.</p> <p>NOTE: That voting system is based on time/date so you can only vote once every 12 hrs.</p> <p>Form code:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;center&gt; Please Enter Your Character Name Below, &lt;br /&gt;&lt;br /&gt; After You Vote Please Relogin And Your Cps Will be Added&lt;br /&gt;&lt;br /&gt; &lt;FORM action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="post"&gt; Character Name: &lt;br /&gt;&lt;br /&gt; &lt;input type="text" name='CharName'&gt;&lt;br&gt; &lt;br /&gt; &lt;input type="submit" name="button" value="Vote"&gt; &lt;/form&gt; &lt;/center&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Vote code:</p> <pre><code>&lt;html&gt;&lt;center&gt; &lt;?php $user = 'test'; //dbuser $pass = 'test'; //dbpass $host = 'localhost'; //dbhost $name = 'zf'; //dbname $con = mysql_connect($host, $user, $pass); mysql_select_db($name, $con); $datetime = date('Y-m-d'); $ip = $_SERVER['REMOTE_ADDR']; if (isset($_POST['button'])) { $result1 = mysql_query("SELECT `level` FROM `cq_user` WHERE `name` = '$char_name'") or die(mysql_error()); while($row = mysql_fetch_array($result1)) { } error_reporting(E_ALL); ini_set('display_errors', '1'); $char_name = $_POST['CharName']; $result = mysql_query("SELECT name FROM cq_user WHERE name = '" . $char_name . "' AND UNIX_TIMESTAMP(lastvoted) &lt;= UNIX_TIMESTAMP('" . date('Y-m-d H:i:s', strtotime('-12 Hours')) . "')") or die(mysql_error()); $result1 = mysql_query("SELECT `level` FROM `cq_user` WHERE `name` = '" . $char_name. "'") or die(mysql_error()); while($row = mysql_fetch_array($result1)) { } if (mysql_num_rows($result) == 0 &amp;&amp; $row &lt;= 119) echo "This character does not exist, or you have entered the wrong name. Or you could be trying to cheat and have already voted. Or you are not level 120+."; else { mysql_query("UPDATE `cq_user` SET `emoney` = `emoney` + 100000, `lastvoted`='" . date('Y-m-d H:i:s') . "' WHERE `name` = '" . $char_name . "'") or die(mysql_error()); mysql_query("UPDATE `cq_user` SET `ip` = '$ip' WHERE `name` = '$char_name'"); ?&gt; &lt;meta http-equiv="REFRESH" content="0;url=http://www.xtremetop100.com/in.php?site=1132303596"&gt;&lt;/HEAD&gt; &lt;?php } } ?&gt; &lt;/html&gt;&lt;/center&gt; </code></pre> <p>Thats my checker</p> <pre><code>if (mysql_num_rows($result) == 0 &amp;&amp; $row &lt;= 119) </code></pre> <p>That's the part where my Level checker should be working the &lt;= 119!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload