简体   繁体   中英

Onsubmit URL Redirection with jquery

I am looking for best way to do Onsubmit URL Redirection.

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

I cant make any changes in dologin.php as it is encoded.

I want me to redirect to clientdetails.php as soon as button is clicked.

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.

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; 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. 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.

But either way, you have to modify dologin.php.

Edit:

@ Randolpho : PHP Files are Ioncube encoded.
– MANnDAaR

So you're trying to hack a third party PHP application that is obfuscated to prevent hacking? I'd approach the PHP application developers to see if they have some mechanism for specifying the redirect. Most login forms allow you to pass the destination URL as a query string parameter. You might even be able to glean the format from your web logs without bothering the developers.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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