Professional Web Applications Themes

Form processing: change the "action=" based on pull down menu - PHP Development

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\" ...

  1. #1

    Default 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

  2. #2

    Default Re: Form processing: change the "action=" based on pull down menu

    Sylvie Stone wrote:
    > 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!
    Hi,

    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; cht=iso-8859-1">
    <meta name="GENERATOR" content="Quanta Plus">

    <script language="javascript">

    function doSubmit(){
    // get the chosen option
    selind = doent.forms.mydynamicform.selectaction.selected Index;
    // get the value
    selval = doent.forms.mydynamicform.selectaction[selind].value;

    // now set this value as action for the form
    doent.forms.mydynamicform.action=selval;

    // and submit
    doent.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

  3. #3

    Default Re: Form processing: change the "action=" based on pull down menu

    [email]sylviestonecanada.com[/email] (Sylvie Stone) wrote in message
    news:<181a24a8.0309160650.45b744dfposting.google. com>...
    >
    > 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".
    >
    > }
    I think you have pretty much figured it out. What I would do if I were
    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

  4. #4

    Default Re: Form processing: change the "action=" based on pull down menu

    [email]sylviestonecanada.com[/email] (Sylvie Stone) wrote in message news:<181a24a8.0309160650.45b744dfposting.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

Similar Threads

  1. Change user role from "Publisher" to "Administrator"
    By trialbomfunknumber2 in forum Macromedia Contribute Connection Administrtion
    Replies: 1
    Last Post: September 19th, 06:51 AM
  2. firefox: <param name="menu" value="false" /> !!!
    By whirled in forum Macromedia Flash Player
    Replies: 1
    Last Post: October 25th, 09:03 AM
  3. #25366 [NEW]: form buttons of type "image" dont send "submit" $_POST variable in IE
    By jordanolsommer at imap dot cc in forum PHP Development
    Replies: 0
    Last Post: September 2nd, 07:54 PM
  4. "save", "selective color" menu go too slow. Please help!
    By bmjun20 in forum Adobe Photoshop 7, CS, CS2 & CS3
    Replies: 1
    Last Post: August 12th, 08:56 PM
  5. "Start" "Program" "Menu" list is empty
    By Pete in forum Windows XP/2000/ME
    Replies: 2
    Last Post: July 10th, 10:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139