简体   繁体   中英

Form action attribute does not work

There is problem in submitting the form. My form tag looks like-

<form method="post" action="classes/action.php" >

this doesn't redirect the page..

Any idea??

more code-

   <div class="grid_12">

      <div class="grid_6 half-c half_m2" align="center" style="border-radius:100px 0 0 100px">
        <form method="post" action="classes/action.php">
            <table>
                <tr>
                    <th colspan="2"><label class="eh1 eh1m">Login as Visitor</label> </th>
                </tr>
                <tr>
                    <td><br /></td>
                    <td></td>
                </tr>
                <tr>
                    <td><label class="eh2">Username</label></td>
                    <td><input type="text" name="txtVUname" class="etxt1 etxtm1"/></td>
                </tr>
                <tr>
                    <td><label class="eh2">Password</label></td>
                    <td><input type="password" name="txtVPwd" class="etxt1 etxtm1"/></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="submit" name="btnVLogin" value="Login" style="float: right" /></td>
                </tr>
            </table>
        </form>

      </div>

      <div class="grid_6 half-c half_m2" align="center" style="border-radius:0 100px 100px 0">
       <form method="post" action="classes/action.php" >
            <table>
                <tr>
                    <th colspan="2"><label class="eh1 eh1m">Login as a Company</label></th>
                </tr>
                <tr>
                    <td><br /></td>
                    <td></td>
                </tr>
                <tr>
                    <td><label class="eh2">Username</label></td>
                    <td><input type="text" name="txtCUname" class="etxt1 etxtm1"/></td>
                </tr>
                <tr>
                    <td><label class="eh2">Password</label></td>
                    <td><input type="password" name="txtCPwd" class="etxt1 etxtm1"/></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="submit" name="btnComLogin" value="Secure Login" style="float: right" /></td>
                </tr>
            </table>
        </form>
      </div>
     </div>

folder structure looks like--

mysite.com
    - classes
            - action.php
    - login.php (containing form)

one more thing.. i can do the same from another page having form and a submit button to redirect on classes/action.php page

You can try this

<form method="post" action="./classes/action.php">

Be careful that file names are case-sensitive in unix!

You should return back by .. So if your form file in the same folder contains the classes folder your code will work, if your form file in internal folder like files/form_file.PHP and the folder files in the same classes folder your code will be:

<form method="post" action="<?php echo $_SERVER['HTTP_HOST']; ?>/classes/action.php" >

And so on.

very simple mistake only. Replace form action and say me the result

 <form method="post" action="../mywebsitename/classes/action.php" >

change the action.php to action2.php and try

<form method="post" action="../mywebsitename/classes/action2.php" >

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