Ask a Question related to PHP Development, Design and Development.
-
Sylvie Stone #1
Form processing: change the "action=" based on pull down menu
Hi group -
I have an html form for that uses username and password to login to a
specific area of the website. The "area" the user wants to go to is
based on a pull down menu. Becasue the user/password info is in
differnet databases, how can I call different validation scripts based
on this input ?
THANK YOU!
See below please. Somethinglike this:
form.html:
<form name="loginform" method="post" action="login.php">
<select name="loginform">
<option value="one">Section 1</option>
<option value="two">Section 2</option>
</select>
login.php:
@extract($_POST);
if($_POST[loginform] == "one") {
echo "action = /forums/scc/dispatch.cgi/_admin/AVFLogin"
NAME="LoginForm" >
echo "<input type=hidden name=\"autologin\" value=\"1\">\n";
echo "<input type=hidden name=\"formstyle\" value=\"standard\">\n";
echo "<input type=hidden name=\"returnforum\" value=\"_admin\">\n";
echo "<input type=hidden name=\"returnmsg\"
value=\"acahomepage\">\n";
} else {
echo "action = /path to different cgi \n";
echo :different values for hidden fields".
}
Sylvie Stone Guest
-
Change user role from "Publisher" to "Administrator"
Have three users on a particular website - all need to be "administrators". Two are listed as administrators (one of which is me), the third is... -
Anyway to "pull-in" data from a website?
I'm using php/mysql. Is there anyway to have a page that will get the data from another webiste page? For example, I want to have a page that... -
#25366 [NEW]: form buttons of type "image" dont send "submit" $_POST variable in IE
From: jordanolsommer at imap dot cc Operating system: Windows XP PHP version: 4.3.2 PHP Bug Type: Variables related Bug... -
"save", "selective color" menu go too slow. Please help!
have intel pentium 4 cpu and photoshop 7. when im using "selective color" or "save" menu (im a novice of photoshop), i have to wait kind of long... -
"Start" "Program" "Menu" list is empty
For what ever reason my list of installed programs in my "Start" "Programs" menu is empty. Anyone know how to restore the list. Thanks for your... -
Erwin Moller #2
Re: Form processing: change the "action=" based on pull down menu
Sylvie Stone wrote:
Hi,> Hi group -
>
> I have an html form for that uses username and password to login to a
> specific area of the website. The "area" the user wants to go to is
> based on a pull down menu. Becasue the user/password info is in
> differnet databases, how can I call different validation scripts based
> on this input ?
> THANK YOU!
This is actually a javascript trick you need.
You can dynamically set the action of a form, just by assigning a new value
to it.
Try something like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<title>formactiontest</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Quanta Plus">
<script language="javascript">
function doSubmit(){
// get the chosen option
selind = document.forms.mydynamicform.selectaction.selected Index;
// get the value
selval = document.forms.mydynamicform.selectaction[selind].value;
// now set this value as action for the form
document.forms.mydynamicform.action=selval;
// and submit
document.forms.mydynamicform.submit();
}
</script>
</head>
<body>
<form action="unknownyet" METHOD="POST" name="mydynamicform">
Choose your action:
<select name="selectaction">
<option value="login1.php">go to login 1</option>
<option value="login2.php">go to login 2</option>
<option value="login3.php">go to login 3</option>
</select>
<br>
Your name? <input type="text" name="yourname" size=10>
<br>
<input type="button" onClick="doSubmit()" value="Go!">
</form>
</body>
</html>
Regards,
Erwin
Erwin Moller Guest
-
Nikolai Chuvakhin #3
Re: Form processing: change the "action=" based on pull down menu
[email]sylviestone@canada.com[/email] (Sylvie Stone) wrote in message
news:<181a24a8.0309160650.45b744df@posting.google. com>...I think you have pretty much figured it out. What I would do if I were>
> I have an html form for that uses username and password to login to a
> specific area of the website. The "area" the user wants to go to is
> based on a pull down menu. Becasue the user/password info is in
> differnet databases, how can I call different validation scripts based
> on this input ?
> THANK YOU!
>
> See below please. Somethinglike this:
>
> form.html:
> <form name="loginform" method="post" action="login.php">
> <select name="loginform">
> <option value="one">Section 1</option>
> <option value="two">Section 2</option>
> </select>
>
> login.php:
>
> @extract($_POST);
> if($_POST[loginform] == "one") {
>
> echo "action = /forums/scc/dispatch.cgi/_admin/AVFLogin"
> NAME="LoginForm" >
> echo "<input type=hidden name=\"autologin\" value=\"1\">\n";
> echo "<input type=hidden name=\"formstyle\" value=\"standard\">\n";
> echo "<input type=hidden name=\"returnforum\" value=\"_admin\">\n";
> echo "<input type=hidden name=\"returnmsg\"
> value=\"acahomepage\">\n";
>
> } else {
>
> echo "action = /path to different cgi \n";
> echo :different values for hidden fields".
>
> }
dealing with this problem (just to make the code base more modular and
easier to maintain) is this:
form.html:
<form method="post" action="login.php">
<select name="loginform">
<option value="1">Section 1</option>
<option value="2">Section 2</option>
</select>
login.php:
switch ($_POST['loginform']) {
case 1:
include ('form1.php');
break;
case 2:
include ('form2.php');
break;
default:
header ('Location: [url]http://'[/url] . $_SERVER['SERVER_NAME'] . '/form.html');
die();
}
That is, if $_POST['loginform'] has a recognizable value, display
the corresponding login form; if not, send the user back to the
choice page. This allows you to have as many login forms as you
want, totally independent of each other, using only one at a time.
Cheers,
NC
Nikolai Chuvakhin Guest
-
Sylvie Stone #4
Re: Form processing: change the "action=" based on pull down menu
[email]sylviestone@canada.com[/email] (Sylvie Stone) wrote in message news:<181a24a8.0309160650.45b744df@posting.google. com>...
> Hi group -
>
> I have an html form for that uses username and password to login to a
> specific area of the website. The "area" the user wants to go to is
> based on a pull down menu. Becasue the user/password info is in
> differnet databases, how can I call different validation scripts based
> on this input ?
> THANK YOU!
THANKS A LOT to Erwin and NC for posting two excellent solutions.
i have taken bits from each and implemented the code and it's working very well.
Thanks again,
Syl.
Sylvie Stone Guest



Reply With Quote

