Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    May 2008
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Form action and post method not working

    Hi all.

    I am trying to create a web form thing for a uni group assignment. Now i had a form defined as below, which worked as i expected it to...

    Code:
    <HTML>
    <TITLE> ***TITLE HERE *** </TITLE>
    
    <HEAD>
    </HEAD>
    
    <BODY>
         <p align="center"><IMG src="Dock.jpg" width=640 height=100 /></p>
         <br />
         
         NOTE: This will only delete the student based on their Student ID!!! <br />
         <form action="confirmDeleteStudent.php" method="post">
         StudentID: <input type="text" name="StudentID" /><br />
         <input type="submit" />
         </form>
    </BODY>
    
    </HTML>
    Now a group member took that ugle page and made it look really nice, but now the form action link is not opened, and the post method isn't working (it simply redirects the page to itself with a url like its was called with the form get method

    Here is the whole code for the new page:
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Delete Student</title>
    <link rel="stylesheet" type="text/css" href="includes/FormStyle.css" />
    </head>
    <body>
    <form id="form1" runat="server">
    <div id="main-container">
    <div id="banner">
    <div id="leftBanner"></div>
    <div id="rightBanner">
    <div id="topBanner"></div>
    <div id="middleBanner">
    <div id="middleBannerLeft"></div>
    <div id="middleBannerRight">
    <!-- <p id="MUheading">
    MACQUARIE UNIVERSITY
    </p>
    <p id="InovHeading">
    AUSTRALIAS INNOVATIVE UNIVERSITY
    </p> -->
    </div>
    </div>
    </div>
    <div id="bottomBanner">
    <h1>Delete Student</h1>
    </div>
    </div>
    <div id="sideBar"></div>
    <?php include("includes/Format.php"); ?>
    <div id="contentPanel">
    <div id="heading">
    <h2>Delete Student</h2>
    <h3>Enter a student number and click Submit</h3>
    </div>

    <div id="innerContentPanel">
    <!-- <p align="center"><IMG src="Dock.jpg" width=640 height=100 /></p> -->
    <br />
    NOTE: This will only delete the student based on their Student ID!!! <br /><br />
    <form action="confirmDeleteStudent.php" method="post">
    StudentID: <input type="text" name="StudentID" /><br /><br />
    <!-- <div id="submitPanel"> -->
    <input type="submit" value="Submit" />
    <!-- </div><br /> -->
    </form>
    </div>
    </div>
    </div>
    </form>
    </body>
    </html>
    Is the problem to do with the fact that the form is in a <div> tag? (and could someone clarify for me, is a <div> just a divider tag so we can apply a css style to it, or is it something else")

    Thanks for reading...
    Last edited by ntb87; 05-24-2008 at 01:47 PM.

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,048
    Thanks
    2
    Thanked 317 Times in 309 Posts
    I recommend examining just the lines with form related tags -

    Code:
    <form id="form1" runat="server">
    
    <form action="confirmDeleteStudent.php" method="post">
    StudentID: <input type="text" name="StudentID" /><br /><br />
    <input type="submit" value="Submit" />
    </form>
    
    </form>
    You will then find that there are nested forms. This is invalid HTML and the first <form ...> tag is what the browser uses. Since the first <form > tag has no action or method parameters the action defaults to the same page and the method defaults to GET.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    Regular Coder
    Join Date
    Sep 2006
    Posts
    216
    Thanks
    9
    Thanked 0 Times in 0 Posts
    I agree with CFMaBiSmAd. The nested <form> tags are invalid and unnecessary. Remove the first <form> tag and the last </form> and it should work OK.

  • #4
    New to the CF scene
    Join Date
    May 2008
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Many thanks guys, that was the problem in the end.
    Thanks for the help!


  •  

    Posting Permissions

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