<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Jul 15, 2007, at 9:35 AM, hazynrg wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hello,<br>I have a login form on /login.php which POSTs to /dorf1.php when access is granted and to /login.php when it is denied.<br><br>require 'rubygems'<br>require 'mechanize'<br>agent = WWW:Mechanize.new ()<br>login = agent.get("<a href="http://server/login.php">http://server/login.php</a>")<br>form = login.forms.action("dorf1.php")<br>form.fields[2].value = "wronguser" # login<br>form.fields [3].value = "wrongpass" # password<br>dorf1 = form.submit()<br>dorf1.uri<br> # => #<URI::<a href="HTTP:0x15af2e04dc7c">HTTP:0x15af2e04dc7c</a> URL:<a href="http://server/dorf1.php">http://server/dorf1.php</a>><br><br>But the page we got was " login.php" (a bit altered: "access denied", etc.)<br>So the URI of the page returned by form.submit() isn't updated if there is a redirect, please fix :)<br>Best regards.</blockquote></div><br><div>Mechanize doesn't support javascript, so if you're changing target based on that, it won't work. If you're using a html meta tag to redirect from dorf1.php back to login.php on failure, I don't think that would work either. But a 302 (header("Location: login.php")) should work.</div><div>-Mat</div></body></html>