gpt4 book ai didi

javascript - 处理响应数据 PHP

转载 作者:行者123 更新时间:2023-11-28 07:56:11 24 4
gpt4 key购买 nike

我创建了这个网站,访问该网站时会自动投票。 http://qthostoi.atspace.cc/sdd.php

问题是,当它提交时,它会下载 index.php 我不希望这样,我怎样才能防止这种情况发生?

源代码:

<html>
<body>
<form action="http://recipes.wikia.com/index.php" method="POST" onsubmit="alert(2)">
<input type="hidden" name="title" value="User&#95;blog&#58;Kate&#46;moon&#47;Battle&#95;of&#95;the&#95;Fantasy&#95;Foods&#45;&#95;Round&#95;SIX" />
<input type="hidden" name="action" value="ajax" />
<input type="hidden" name="rs" value="axAjaxPollSubmit" />
<input type="hidden" name="wpPollId" value="B5686B741937166683ACC4DC49C515BB" />
<input type="hidden" name="wpVote" value="Vote&#33;" />
<input type="hidden" name="wpPollRadioB5686B741937166683ACC4DC49C515BB" value="3" />
<input type="submit" value="Submit request" />
</form>
<script>
document.forms[0].submit();
</script>
</body>
</html>

我尝试过这些:

1:

<?php

$url = 'http://recipes.wikia.com/index.php';
$fields = array(
'title' => "User&#95;blog&#58;Kate&#46;moon&#47;Battle&#95;of&#95;the&#95;Fantasy&#95;Foods&#45;&#95;Round&#95;SIX",
'action' => "ajax",
'rs' => "axAjaxPollSubmit",
'wpPollId' => "B5686B741937166683ACC4DC49C515BB",
'wpVote' => "Vote&#33;",
'wpPollRadioB5686B741937166683ACC4DC49C515BB' => "3",
);
$count = count($fields);
$fields = http_build_query($fields);
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_POST, $count);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields);
$result = curl_exec($ch);
curl_close($ch);

echo $result;
?>

这确实会收到响应并阻止下载,但它不会将我的数据提交到其他域。我认为它提交了错误的数据。

2:

<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
</head>

<body>

<script>
$("#contactForm").submit(function(event)
{
/* stop form from submitting normally */
event.preventDefault();

/* get some values from elements on the page: */
var $form = $( this ),
$submit = $form.find( 'button[type="submit"]' ),
title_value = $form.find( 'input[name="title"]' ).val(),
action_value = $form.find( 'input[name="action"]' ).val(),
rs_value = $form.find( 'input[name="wpPollId"]' ).val(),
wpPollId_value = $form.find( 'input[name="title"]' ).val(),
wpVote_value = $form.find( 'input[name="wpVote"]' ).val(),
wpPollRadioB5686B741937166683ACC4DC49C515BB_value = $form.find( 'input[name="wpPollRadioB5686B741937166683ACC4DC49C515BB"]' ).val(),
message_value = $form.find( 'textarea[name="message"]' ).val(),
url = $form.attr('action');

/* Send the data using post */
var posting = $.post( url, {
title: title_value,
action: action_value,
rs: rs_value,
wpPollId: wpPollId_value,
wpVote: wpVote_value,
wpPollRadioB5686B741937166683ACC4DC49C515BB: wpPollRadioB5686B741937166683ACC4DC49C515BB_value
});

posting.done(function( data )
{
/* Put the results in a div */
$( "#contactResponse" ).html(data);

/* Change the button text. */
$submit.text('Sent, Thank you');

/* Disable the button. */
$submit.attr("disabled", true);
});
});
</script>

<form id="contactForm" action="http://recipes.wikia.com/index.php" Method="POST">
<input type="hidden" name="title" value="User&#95;blog&#58;Kate&#46;moon&#47;Battle&#95;of&#95;the&#95;Fantasy&#95;Foods&#45;&#95;Round&#95;SIX" />
<input type="hidden" name="action" value="ajax" />
<input type="hidden" name="rs" value="axAjaxPollSubmit" />
<input type="hidden" name="wpPollId" value="B5686B741937166683ACC4DC49C515BB" />
<input type="hidden" name="wpVote" value="Vote&#33;" />
<input type="hidden" name="wpPollRadioB5686B741937166683ACC4DC49C515BB" value="3" />
<input type="submit" value="Submit request" />
</form>
<div id="contactResponse"></div>



</body>
</html>

它确实提交了我的数据,但下载了 index.php

有什么帮助吗?

最佳答案

您可以使用 jQuery 发布表单并捕获 json 响应。尝试这样的事情:

<html>
<body>
<form action="http://recipes.wikia.com/index.php" method="POST" onsubmit="alert(2)">
<input type="hidden" name="title" value="User&#95;blog&#58;Kate&#46;moon&#47;Battle&#95;of&#95;the&#95;Fantasy&#95;Foods&#45;&#95;Round&#95;SIX" />
<input type="hidden" name="action" value="ajax" />
<input type="hidden" name="rs" value="axAjaxPollSubmit" />
<input type="hidden" name="wpPollId" value="B5686B741937166683ACC4DC49C515BB" />
<input type="hidden" name="wpVote" value="Vote&#33;" />
<input type="hidden" name="wpPollRadioB5686B741937166683ACC4DC49C515BB" value="3" />
<input type="submit" value="Submit request" />
</form>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(function() {

var data = $("form").serializeArray();

$.post('http://recipes.wikia.com/index.php', data, function(jsonResponse){

var jsonObj = $.parseJSON(jsonResponse);
alert("The id: " + jsonObj.id);

});
});
</script>

</body>
</html>

关于javascript - 处理响应数据 PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26058839/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com