Making cross domain get request
okay so I have this link
<a id="link" href="https://yahoo.com" target="blank">Link</a>
then i have this script:
var security = function(){
var link = $('#link').attr('href');
$.getJSON('http://myweb.com/func.php',function(result){
if (result % 5 === 0){
$('#link').attr("href", link);
alert('his link');
}else{
$('#link').attr('href','https://google.com');
alert('your link');
}
});
$("#link").click(function(){
$.getJSON('http://myweb.com/func2.php',function(results){
if (results === results){
location.reload();
}
});
});
};
func.php:
$results = mysqli_query($con,"SELECT * FROM `c_clicks`");
while ($row = mysqli_fetch_array($results)) {
$clicks = $row['id'];
echo $clicks;
}
func2.php:
$results = mysqli_query($con,"INSERT INTO `c_clicks`(`link`,`date`)
VALUES('claim',now())");
What I'm trying to accomplish is that for every 5 clicks the #link will
send the user to another domain. The thing is it works fine but if someone
rips my website and switches the #link href func.php and func2.php are no
longer accesible so they dont work. I tried fixing it with JSON but im
guessing its wrong. How could I still perform func and func2 through a
different server?
No comments:
Post a Comment