如何在没有实际离开PHP站点的情况下将帖子提交到站点

时间:2012-10-23 22:49:39

标签: php javascript

所以我有这个链接器,您可以从我的应用程序登录到您的帐户(它的出价网站)。问题是它会将您发送到该页面并将您登录。有没有办法让$_POST[]提交并登录到站点而不实际离开链接器所在的站点。

如果您需要查看任何内容,请与我们联系。

非常感谢你!

更新---------------使用jquery

<div class="linkdimesAccount">
<form name="aspnetForm" method="post" action="http://1betvegas.com/default.aspx" onkeypress="javascript:return WebForm_FireDefaultButton(event, 'ctl00_MainContent_ctlLogin_BtnSubmit')" id="aspnetForm" style="margin: 0 0 0 0;">
            <script type="text/javascript">
                //<![CDATA[
                var theForm = document.forms['aspnetForm'];
                if (!theForm) {
                    theForm = document.aspnetForm;
                }
                function __doPostBack(eventTarget, eventArgument) {
                    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
                        theForm.__EVENTTARGET.value = eventTarget;
                        theForm.__EVENTARGUMENT.value = eventArgument;
                        theForm.submit();
                    }
                }
                //]]>
                </script>
             <div>
            <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="">
            <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="">
            <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="eYjk1H7gGdxNJmuevBY9L0vo1lS2NWgmApCJFEQznQr+AwZaPf/hYV4iGSnPCSknyHjESN/BgHueeChVuGgmN4wtWFCdUaYPJRItirNF0nIBHe9Q">
            </div>
            <script src="/WebResource.axd?d=FrT3YL7-WvrI_DKD4vsDo2d0Al_8j_u_HUym76C9Z5ggdJlIe1yu5cWI_jZDYcizjTU0SkefrocS8ATa0&amp;t=634604245351482412" type="text/javascript"></script>
            <div>

                <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="yepc3zJ4Kjr5ru/aXm+s9SqYXyFoM+cwIlWPI69lDMnO4eybZJ1cM1pfzowM47Ggezne5505JNUx/VGe3XO8OCmvZnghqv8ZCuJm+yffjs4inz2n6ctjK/0F/qER0ARSznB8iJsMIZ7HxPXA/Stv+0ubH0U=">
            </div>
            <h2>Link your 5dimes account</h2>

                <table>
                    <tr>
                    <?php
                    if ($dimesaccount == 1){
                    echo "<h2 style='color:red;'> Please note your account is already linked.  If password or other information has changed please re-enter your username and password";
                    }
                    ?>
                        <td>
                        Username:
                        </td>
                         <td>
                            <input name="ctl00$MainContent$ctlLogin$_UserName" type="text" size="15" id="ctl00_MainContent_ctlLogin__UserName" accesskey="u" tabindex="60" class="login_input">
                        </td>
                    </tr>
                    <tr>
                     <td>
                        Password:
                        </td>
                    <td>
                        <input name="ctl00$MainContent$ctlLogin$_IdBook" type="hidden" id="ctl00_MainContent_ctlLogin__IdBook">
                        <input name="ctl00$MainContent$ctlLogin$Redir" type="hidden" id="ctl00_MainContent_ctlLogin_Redir" value="wager/welcome.aspx">
                        <input name="ctl00$MainContent$ctlLogin$_Password" type="password" size="15" id="ctl00_MainContent_ctlLogin__Password" accesskey="p" tabindex="61" class="login_input">
                    </td>
                    </tr>
                    <tr>
                    <td>
                        <input type="submit" name="ctl00$MainContent$ctlLogin$BtnSubmit" value="Link" id="ctl00_MainContent_ctlLogin_BtnSubmit" class="login_input" style="text-transform: uppercase;">
                    </td>
                    </tr>

                </table>


        </div><!-------.linkdimesAccount ------>
        </form>
        <div id="result"></div>
        <script>
  /* attach a submit handler to the form */
  $("#aspnetForm").submit(function(event) {

    /* stop form from submitting normally */
    event.preventDefault(); 

    /* get some values from elements on the page: */
    var $form = $( this ),
        term = $form.find( 'input[name="__EVENTTARGET"]' ).val(),
        term1 = $form.find( 'input[name="__EVENTARGUMENT"]' ).val(),
        term2 = $form.find( 'input[name="__VIEWSTATE"]' ).val(),
        term3 = $form.find( 'input[name="ctl00$MainContent$ctlLogin$_UserName"]' ).val(),
        term4 = $form.find( 'input[name="ctl00$MainContent$ctlLogin$_IdBook"]' ).val(),
        term5 = $form.find( 'input[name="ctl00$MainContent$ctlLogin$Redir"]' ).val(),
        term6 = $form.find( 'input[name="ctl00$MainContent$ctlLogin$_Password"]' ).val(),
        term7 = $form.find( 'input[name="ctl00$MainContent$ctlLogin$BtnSubmit"]' ).val(),

        url = $form.attr( 'action' );

    /* Send the data using post and put the results in a div */
    $.post( url, { s: term, s: term1, s: term2, s: term3, s: term4, s: term5, s: term6, s: term7 },
      function( data ) {
          var content = $( data ).find( '#content' );
          $( "#result" ).empty().append( content );
      }
    );
  });
</script>

因此,在运行此操作时,它会将我带到登录页面,即使它应该在事件停止时停止。

2 个答案:

答案 0 :(得分:2)

如果您不想使用javascript / jquery,可以发布到iframe:

http://css-tricks.com/snippets/html/post-data-to-an-iframe/

这增加了能够处理文件上传的能力。这是在提交表单时不离开页面的好方法。如果你想要jquery,请看其他人回答,也没关系。

答案 1 :(得分:1)

尝试jQuery $.post(url, data, function(a,b){..manage success result..})

相关问题