我试图搜索但是我没有找到任何解决方案在windows.location.href =“”中插入一个sql变量;
我已经尝试过这个:
window.location.href = "<?php echo $up1 ?>"
中找到
但它没有用,而且我已经搜索了,但我仍无法在网上找到任何内容。
我试过这个例子,但我认为我这样做的方式不正确。
我的所有代码:
<?php
$up1 = $userRow['up1'];
session_start();
include_once 'dbconnect.php';
if(!isset($_SESSION['user']))
{
header("Location: index.php");
}
mysql_real_escape_string($user_id);
mysql_real_escape_string($user_name);
mysql_real_escape_string($user_points);
mysql_real_escape_string($user_voucher);
mysql_real_escape_string($user_level);
mysql_real_escape_string($user_wallet);
$res=mysql_query("SELECT up1 FROM settings");
$userRow=mysql_fetch_array($res);
$up1 = $up1;
?>
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
</div>
<script type='text/javascript'>
document.onkeydown = function (e) {
var key = e.charCode || e.keyCode;
if (key == 13) {
// enter key do nothing
} else {
e.preventDefault();
}
}
</script>
<script>
window.oncontextmenu = function () {
console.log("Right Click Disabled");
return false;
}
</script>
<script type="text/javascript">
function disableselect(e){
return false
}
function reEnable(){
return true
}
//if IE4+
document.onselectstart=new Function ("return false")
document.oncontextmenu=new Function ("return false")
//if NS6
if (window.sidebar){
document.onmousedown=disableselect
document.onclick=reEnable
}
</script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div id='exemple' data-up='<?php echo $up1;?>'>
<script>
function goToBing() {
//window.location.href = "<?php echo $up1; ?>"
var test=$("#exemple").attr('data-up);
window.location.href=test;
}
</script>
<br>
<br>
<br>
<br>
<center><a href="http://bitcoinrotator.publiadds.org.pt" onclick="goToBing();return false;">Click To Confirm Please</a></center>
</body>
</html>
答案 0 :(得分:0)
你可以使用:
<div id='exemple' data-up='<?php echo $up1;?>'>
</div>
在jquery中:
var test=$("#exemple").attr('data-up);
window.location.href=test;