Note that there are some explanatory texts on larger screens.

plurals
  1. POPossible injection from date string Select query
    primarykey
    data
    text
    <p>I have a problem wich is a little strange. My page contains a html link which refreshes the page and calls a PHP variable. This variable appends a date string to the url string which is fed into a MySQL query, which grabs records matching this date. I think this is causing an injection as it sometimes deletes the user from the database!</p> <p>I know there may be security issues using the '#' in the hyperlink, but I'd like to know whats going on. Also would this have different effects on different browsers seeing as how it uses javascript. The users being deleted seems to happen only on some peoples computers.</p> <p>The PHP code calculates a timestamp three days from now and then puts it into a SQL format:</p> <pre><code>$ts_threeDays = mktime(1,0,0,date('m'), date('d')+3-date('w'), date('y')); $threeDaysAhead = date('y-m-d', $ts_second_day); </code></pre> <p>The script then listens for the 'day' variable in the url string passed by the hyperlink on the page:</p> <pre><code>$date = mysql_real_escape_string($_GET['day']); </code></pre> <p>The JavaScript and hyperlink is:</p> <pre><code>&lt;a href='#' onClick="document.location.href='planner.php?day=&lt;?php echo $threeDaysAhead; ?&gt;'"&gt; 3 Days Later&lt;/a&gt; </code></pre> <p>The MySQL query is bigger but the only input it takes from user action is the above date string. Query basically looks like this (uses another select statement to access users table):</p> <pre><code>SELECT planner.details FROM planner WHERE planner.date = '$date' AND users.`user_id` = '$id' // Logged in Id superglobal </code></pre> <p>If anyone can help me out and explain my problem I will be most grateful. Many thanks</p>
    singulars
    1. This table or related slice is empty.
    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.
    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