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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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>
Link to comment
Share on other sites

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>';
}

?>
Edited by Ch0cu3r
Link to comment
Share on other sites

<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

Edited by Barand
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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