You are here: Re: Submit form with variable for action? « PHP Programming Language « IT news, forums, messages
Re: Submit form with variable for action?

Posted by Toby Inkster on 09/26/05 00:32

tencip wrote:

> <form action="http://www.mysite.com/admin/index.php" method="post"
> name="login" id="login" >
> <input name="usrname" type="text">
> <input name="pass" type="password">
> <input name="domain" type="text">
> <input name="submit" type="submit" value="Login">
> </form>
>
> Now, the issue is, instead of the action I have now, I need the action
> to change based on what is typed by the user in the domain field.

Is method="post" set in stone?

If not, the easy solution is this:

<form action="somefile.php" method="get">
<input name="usrname">
<input name="pass" type="password">
<input name="domain">
<input type="submit" value="Login">
</form>

The form will *always* submit to "somefile.php", but then from
somefile.php we redirect to the correct location:

<?php
$url = sprintf("http://%s/admin/index.php?usrname=%s&pass=%s",
$_REQUEST['domain'], $_REQUEST['usrname'], $_REQUEST['pass']);
header("Location: $url");
?>
<title>Redirect</title>
<h1>Redirect</h1>
<p><a href="<?=$url?>"><?=$url?></a></p>

Of course, if you use GET rather than POST you have the problem of the
password being part of the URL, in plain sight.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация