简体   繁体   English

使PHP单击同一页面上的链接或处理表单

[英]Make PHP Click Link On Same PAge Or Process A Form

Is there any php code i can use to click a link or process a form on the page the php is on? 我可以使用任何php代码单击链接或处理php所在页面上的表单吗?

Im building a redirect script and what i need to do is use php to move user to next page, its mandatory that php has to be used html doesnt work. 我正在建立一个重定向脚本,我需要做的是使用php将用户移动到下一页,它必须使用html来强制执行php,这是行不通的。 In it i have a self submit forum but it doesnt work how i load the script. 在它我有一个自我提交论坛,但它不起作用,我如何加载脚本。 Is there a way i can use php code to submit it? 有没有一种方法可以使用php代码提交? or remove it and put a link there then use php to click that link? 或删除它,并放置一个链接,然后使用php单击该链接?

This is the code below: 这是下面的代码:

if ($_GET['ref_spoof'] != NULL) 
{
    $offer = urldecode($_GET['ref_spoof']);
    $p1 = strpos ($offer, '?') + 1;
    $url_par = substr ($offer , $p1);
    $paryval = split ('&', $url_par);
    $p = array();
    foreach ($paryval as $value) 
    {
        $p[] = split ('=',$value);
    }
    //header('Location: '.$offer.'') ;
    print 
    '
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    </head>
    <body>
    <script src="http://code.jquery.com/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript">$("#mylink").click()</script>
    <a href="'.$offer.'" id="mylink">Index Page</a>
    <script type="text/javascript">$("#mylink").click()</script>
    <script type="text/javascript">document.getElementById("myLink").click();</script>


    <form action="'.$offer.'" method="get" id="myform">
    ';
    foreach ($p as $value) 
    {
        echo '<input type="hidden" name="'.$value[0].'" value="'.$value[1].'">';

    }
    echo '</form><script language="JavaScript"> document.getElementById(\'myform\').submit();</script></body></html>';

}

Looks like you're trying to make this too complicated. 看起来您正在尝试使它变得过于复杂。 You're loading a page that submits a form using GET. 您正在加载一个页面,该页面使用GET提交表单。

Is there any reason you can't use 有什么原因不能使用

       header("Location : ".$offer."?".http_build_query($p));

http_build_query being a function to generate an URL string from an array. http_build_query是从数组生成URL字符串的函数。 Assuming $p is the array containing all form fieldnames+values. 假设$ p是包含所有表单字段名和值的数组。

example of http_build_query: http_build_query的示例:

      $data = array('foo'=>'bar',
          'baz'=>'boom',
          'cow'=>'milk',
          'php'=>'hypertext processor');

    echo http_build_query($data);
    will result in:
    foo=bar&baz=boom&cow=milk&php=hypertext+processor

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM