Edit: Hmm, where did the entire thread go? Or have I posted in the wrong thread?
Edit: Since this seems to be a cross post, I suppose it doesn't matter. But perhaps someone could merge this with http://www.phpbuilder.com/board/showthread.php?t=10382976
MOD EDIT: Cross posted indeed - threads merged.
listenmirndt;10994830 wrote:
'&q1='+'<?php echo $q1; ?>'+'&q2='+'<?php echo $q2; ?>'
"WHERE $q1 = '$q2'";
This is not good. If you let both q1 and q2 come from the browser, you must make certain that they are what you expect. It doens't matter if you actually set them to fixed values in your javascript, since there is no guarantee that a user is actually using your clientside code. They might just as well forge their own request, and if they set q1 and q2 to 1, then you get
WHERE 1='1'
which evaluates to true. Thus you'd update all rows in table. Also, $q1 should be checked against a group of ok identifiers to use. For example
$where_idents = array('field1' => 'int', 'field3' => 'string');
if (!in_array($q1, $where_idents))
{
$where = '';
}
else
{
if ($where_idents[$q1] == 'string')
{
$where = " WHERE $q1 = '" . mysql_real_escape_string($q2). "'"
}
elseif ($where_idents[$q] == 'int')
{
$where = " WHERE $q1 = " . (int)*$q2;
}
}
$query = mysql_query($sql . $where);
Krik;10994838 wrote:
You can not set the $GET or $POST superglobals in php.
Actually, you can, although I wouldn't recommend it. Leaving them as is upon request means you will never risk using them later on while believing they have been sanitized when in fact they have not. Also, you may sometimes wish them first escaped in one way, say for a mysql query, and then in another, say for a html document.
listenmirndt;10994830 wrote:So I am not sure if the issue is PHP or Javascript, I am using this JS code:
http.open('get'
Notice that you are doing a GET and not a POST request.
Thus, to see what the requested URI querystring looks like
alert('postvar='+postnew+'&nocache = '+nocache+'&field='+'<?php echo $link; ?>'+'&page='+'<?php echo $_GET[page]; ?>'+'&id='+'<?php echo $_GET[id]; ?>'+'&theme='+'<?php echo $rowxxx[THEME]; ?>'+'&table='+'<?php echo $ajaxtable; ?>'+'&q1='+'<?php echo $q1; ?>'+'&q2='+'<?php echo $q2; ?>');
Since I don't know what data goes where, I can't be certain, but I'd bet that the CSS code you posted is put into the query string without being properly escaped, thus giving you something like
http://example.com?var=123#this_is_a_fragment_identifier_and_not_part_of_the_query_string
Do note that the fragment identifier isn't sent to the server. It's used to locate an element and scroll it into view, which in HTML 5 means:
the first element whose id equals the fragment identifier
or failing that the first element whose name equals the fragment identifier