...

View Full Version : Form action and post method not working



ntb87
05-24-2008, 01:25 PM
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...



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

CFMaBiSmAd
05-24-2008, 02:32 PM
I recommend examining just the lines with form related tags -



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

alex57
05-25-2008, 02:31 PM
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.

ntb87
05-26-2008, 08:51 AM
Many thanks guys, that was the problem in the end.
Thanks for the help!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum