简体   繁体   English

jQuery的Onsubmit URL重定向

[英]Onsubmit URL Redirection with jquery

I am looking for best way to do Onsubmit URL Redirection. 我正在寻找执行“提交URL重定向”的最佳方法。

Currently I have form like this... 目前我有这样的表格...

<form action="dologin.php?" method="post" id="frmlogin">    
<input type="hidden" value="something" />    
<input type="submit" value="go" />

Currently this dologin.php is directing me to clientarea.php 目前,此dologin.php将我定向到clientarea.php

I cant make any changes in dologin.php as it is encoded. 由于编码,我无法在dologin.php中进行任何更改。

I want me to redirect to clientdetails.php as soon as button is clicked. 我希望我在单击按钮后立即重定向到clientdetails.php

How can I achieve ? 我该如何实现?

Thanks 谢谢

UPDATE 更新

Currently How I do this.... 目前我该如何做...。

<script type="text/javascript" language="javascript">
        function redirect() {
            window.location.href = '/clientarea.php?action=details';
        }
</script>


<form action="dologin.php?" onsubmit="setTimeout('redirect()', 1000);" method="post" id="frmlogin">    
<input type="hidden" value="something" />    
<input type="submit" value="go" />

This Do my purpose, Even if login credentials fails it stick to login page with defining errors. 这可以达到我的目的,即使登录凭据失败,它也会停留在带有定义错误的登录页面上。

I was just looking for if there is any better/another way of doing it. 我只是在寻找是否有更好/另一种方法。

Modify the form action to read as such: 修改表单操作,使其如下所示:

<form action="clientdetails.php" method="post"> <!-- etc. -->

Bam your form now posts directly to clientdetails.php. 现在,Bam您的表单直接发布到clientdetails.php。

Now, if you want to submit to dologin.php and then move to clientdetails.php, perhaps because dologin.php does some processing that you want, you're out of luck; 现在,如果您想提交到dologin.php,然后再转到clientdetails.php,也许是因为dologin.php完成了您想要的某些处理,您就不走运了。 there's no way you can do a redirect client-side without making sure that the submission to dologin.php returns the correct javascript to redirect to the desired URL. 如果您不确保向dologin.php提交的提交返回正确的javascript以重定向到所需的URL,则无法进行客户端重定向。 Of course, you'd be better off making dologin.php send an HTTP redirect instead, but if you are dead-set on doing it with javascript, you can do it that way. 当然,最好还是让dologin.php发送一个HTTP重定向,但是如果您对使用javascript陷入僵局,则可以这样做。

But either way, you have to modify dologin.php. 但是无论哪种方式,您必须修改dologin.php。

Edit: 编辑:

@ Randolpho : PHP Files are Ioncube encoded. @ Randolpho:PHP文件是Ioncube编码的。
– MANnDAaR –曼达

So you're trying to hack a third party PHP application that is obfuscated to prevent hacking? 因此,您正在尝试破解被混淆以防止黑客入侵的第三方PHP应用程序吗? I'd approach the PHP application developers to see if they have some mechanism for specifying the redirect. 我将与PHP应用程序开发人员联系,以了解他们是否具有用于指定重定向的机制。 Most login forms allow you to pass the destination URL as a query string parameter. 大多数登录表单都允许您将目标URL作为查询字符串参数传递。 You might even be able to glean the format from your web logs without bothering the developers. 您甚至可以从Web日志中收集格式,而无需打扰开发人员。

Either way, you should clearly indicate that you're working with third-party code in your question. 无论哪种方式,您都应该在问题中明确指出您正在使用第三方代码。 We can't help you solve your problem without sufficient information. 没有足够的信息,我们将无法帮助您解决问题。

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

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