Jump to content

i put different action but when i hit submit it still bring me to the same page


dean012

Recommended Posts

<form action ="trip1.php" method="post">
	<p><input type="checkbox" name="agree" /> Auckland</p>
<form action ="trip.php" method="post">
	<p><input type="checkbox" name="agree" /> North Shore</p>

	<p><input type="checkbox" name="agree" /> Waikato</p>
	<p><input type="checkbox" name="agree" /> Taranaki</p>
	<p><input type="checkbox" name="agree" /> Toupo</p>
	<p><input type="checkbox" name="agree" /> Wellington/p>
	<p><input type="checkbox" name="agree" /> Bay of Plenty</p>
	<p><input type="checkbox" name="agree" /> Manukau</p>
	<p><input type="submit" value="submit" /></p>
			</div>

i put different action but when i hit submit it still bring me to the same page

You've got a form within form which you can't so. If you need two separate forms on a page you will need to close them properly then using JavaScript is the easiest way to submit different forms.

 

<form action ="trip1.php" method="post" name="form1">

<p><input type="checkbox" name="agree" /> Auckland</p>

</form>

<form action ="trip.php" method="post" name="form2">

<p><input type="checkbox" name="agree" /> North Shore</p>

 

<p><input type="checkbox" name="agree" /> Waikato</p>

<p><input type="checkbox" name="agree" /> Taranaki</p>

<p><input type="checkbox" name="agree" /> Toupo</p>

<p><input type="checkbox" name="agree" /> Wellington/p>

<p><input type="checkbox" name="agree" /> Bay of Plenty</p>

<p><input type="checkbox" name="agree" /> Manukau</p>

<p><input type="submit" value="submit" onclick="form2.submit();"/></p>

</div>

</form>

and so far i tried

<form action ="taupo.php" method="post" name="form1">
<p><input type="checkbox" name='agree[]' /> Auckland</p>
</form>
<form action ="hamilton.php" method="post" name="form2">
<p><input type="checkbox" name='agree[]' /> North Shore</p>
</form>
	<p><input type="checkbox" name='agree[]' /> Waikato</p>
	<p><input type="checkbox" name="agree[]" /> Taranaki</p>
	<p><input type="checkbox" name="agree[]" /> Taupo</p>
	<p><input type="checkbox" name="agree[]" /> Wellington/p>
	<p><input type="checkbox" name="agree[]" /> Bay of Plenty</p>
	<p><input type="checkbox" name="agree[]" /> Manukau</p>
	<p><input type="submit" value="submit" onclick="form2.submit();"/></p>
		
    </div>

</form>

Not sure what you're wanting to do, but if you want the user to select multiple locations you'd setup the form like

<form action ="location.php" method="post">
	<p><input type="checkbox" name="locations[]" value="Auckland" /> Auckland</p>
	<p><input type="checkbox" name="locations[]" value="North Shore" /> North Shore</p>
	<p><input type="checkbox" name="locations[]" value="Waikato" /> Waikato</p>
	<p><input type="checkbox" name="locations[]" value="Taranaki" /> Taranaki</p>
	<p><input type="checkbox" name="locations[]" value="Taupo" /> Taupo</p>
	<p><input type="checkbox" name="locations[]" value="Wellington" /> Wellington/p>
	<p><input type="checkbox" name="locations[]" value="Bay of lenty" /> Bay of Plenty</p>
	<p><input type="checkbox" name="locations[]" value="Manukau" /> Manukau</p>
	<p><input type="submit" name="submit" value="submit" /></p>
</form>

The location goes in the value="" attribute for each checkbox. Then in location.php the $_POST['locations'] variable will contain an array of selected locations.

 

Example code for location.php, for displaying the selected locations

<?php

if(isset($_POST['submit']))
{
	echo 'You have selected the following locations: ';
	echo '<ul><li>' . implode('</li><li>', $_POST['locations']) . '</li></ul>';
}

?>
<form action ="taupo.php" method="post" name="form1">
<p><input type="checkbox" name='agree[]' /> Auckland</p>
</form>
<form action ="hamilton.php" method="post" name="form2">
<p><input type="checkbox" name='agree[]' /> North Shore</p>
</form>                                                                   <--- Your 2nd form ends here!
    <p><input type="checkbox" name='agree[]' /> Waikato</p>                    Anything below is not in a form 
    <p><input type="checkbox" name="agree[]" /> Taranaki</p>
    <p><input type="checkbox" name="agree[]" /> Taupo</p>
    <p><input type="checkbox" name="agree[]" /> Wellington/p>
    <p><input type="checkbox" name="agree[]" /> Bay of Plenty</p>
    <p><input type="checkbox" name="agree[]" /> Manukau</p>
    <p><input type="submit" value="submit" onclick="form2.submit();"/></p>
        
    </div>

</form>

Your first form has no submit button

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.