Odd Self Submitting Form Behavior
Posted: Sun May 09, 2010 2:48 am
I have a page, index.php that has an include file for the header, one for the side bar and one for the main body.
The include for the main body is a form and the form is self submitting. All of the form code is in the included file.
Each of my forms has a button that refers back to the other form (this is just a test so far).
Each time I click on the button, a . gets added to the end of my URL. http://localhost/template.php then it's http://localhost/template.php. then http://localhost/template.php.. and so on each time I click submit.
I'm not using $_GET[] at all so I just don't understand why it's happening. Everything works right but this is strange behavior.
Here's some code:
The include for the main body is a form and the form is self submitting. All of the form code is in the included file.
Each of my forms has a button that refers back to the other form (this is just a test so far).
Each time I click on the button, a . gets added to the end of my URL. http://localhost/template.php then it's http://localhost/template.php. then http://localhost/template.php.. and so on each time I click submit.
I'm not using $_GET[] at all so I just don't understand why it's happening. Everything works right but this is strange behavior.
Here's some code:
Code: Select all
//from the top of template.php
?php session_start();
if(isset($_POST['submit'])) {
$include = $_POST['submit'];
}
Else {
$include = "/includes/incl_index.php";
}
?>
//other html code omitted - no php
//from the body of the template.php
<div id="mainContent">
<?php include($include);
echo $include; ?>
</div>
Code: Select all
//from incl_index.php .. the entire contents
<h1>THIS IS A SUCCESFUL TEST</h1><br>
<FORM NAME = 'INDEXFORM' ACTION=<?php echo $_SERVER['PHP_SELF'];?>. METHOD=POST>
<input NAME = 'submit' type=SUBMIT VALUE='/includes/incl_submit_test.php'>
</FORM>
Code: Select all
//from incl_submit_test.php .. the entire contents
<h1>THIS IS A SUCCESFUL SUBMIT TEST</h1><br>
<FORM NAME = 'INDEXFORM' ACTION=<?php echo $_SERVER['PHP_SELF'];?>. METHOD=POST>
<input NAME = 'submit' type=SUBMIT VALUE='/includes/incl_index.php'>
</FORM>