George_Fal 2018-11-22 22:05 采纳率: 0%
浏览 40

提交后获取内容

i had this script auto login after submit the link will change and i want to download the next page automatic what i should add after the last line here is my code

<?php
$homepage = file_get_contents('localhost/test/login.php');
echo $homepage;
?>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.min.js" ></script>
<script type="text/javascript">
  $(function(){
    $("input[name=email]").val("test@test.com");
    $("input[name=password]").val("test");
    $('#signin-form').submit();
  });
</script>

this script is in another file named auto.php . so when i run it's work but after the submit the link localhost/login.php will redirect to localhost/index.php so what i should add to auto.php after submit to get the content of localhost/index.php thank you

  • 写回答

1条回答 默认 最新

  • weixin_33724570 2018-11-23 00:12
    关注

    Due to the lack of details, I will explain a solution (what I've got from your question).

    Imagine you have a form in the auto.php page that will send some data to index.php. You asked for an approach to retrieve data/results from index.php without redirecting or something alike. This is a way you can do it by ajax:

    $('#signin-form').on('click', function(e){
        //e.preventDefault();
        var email= $("input[name=email]").val();
        var password = $("input[name=password]").val();
        $.ajax({
                url: 'index.php',
                type: 'POST',
                data: 'the_email='+ email +'the_pass'+ password ,
                success: function(respond){
                    $('#results').html(respond);
                }
            });
    });
    

    In index.php use $_POST['the_email'] for email and $_POST['the_pass'] for password. Use them, manipulate them or whatever you want, and then echo the results in index.php.

    Please note: in order to show the results, you have to add new div with #results id in auto.php. Like below:

    <div id="results"></div>

    Now all data from index.php will be shown in auto.php without redirecting.

    评论

报告相同问题?

悬赏问题

  • ¥20 python忆阻器数字识别
  • ¥15 无法输出helloworld
  • ¥15 高通uboot 打印ubi init err 22
  • ¥20 PDF元数据中的XMP媒体管理属性
  • ¥15 R语言中lasso回归报错
  • ¥15 网站突然不能访问了,上午还好好的
  • ¥15 有没有dl可以帮弄”我去图书馆”秒选道具和积分
  • ¥15 semrush,SEO,内嵌网站,api
  • ¥15 Stata:为什么reghdfe后的因变量没有被发现识别啊
  • ¥15 振荡电路,ADS仿真