Page 1 of 1

[Solved] Posting to multiple URLs through one form

Posted: Sun Mar 21, 2004 6:38 pm
by mjseaden
Dear All

I have a data form. On this data form are a variety of text INPUT objects, as well as a few FILE objects.

Also on this page are 'Preview Post', 'Clear Form', 'Submit Form' and 'Upload Pictures' buttons, each of which need the information contained within the form.

However, using the ACTION parameter for the form, I can only stipulate one target URL for any submit buttons embedded in the form.

I want to be able to use the image buttons (Preview, Clear, Submit, Upload) described above to go to their corresponding URLs, but also for those URLs to receive the corresponding POST information from the data form.

Seeing as I can only use one URL through stipulating the ACTION parameter in the FORM, how can I post the information on the forms to each of those URLs separately?

I hope that's clear.

Many thanks

Mark

Posted: Sun Mar 21, 2004 6:53 pm
by mjseaden
In case that isn't clear, maybe this will help:

Code: Select all

<FORM METHOD="post" ACTION="???.php">
<INPUT TYPE="text" LENGTH="3">
<INPUT TYPE="text" LENGTH="10">
<INPUT TYPE="file">
<A HREF="preview.php"><IMG SRC="preview.jpg"></A>
<A HREF="clear.php"><IMG SRC="clear.jpg"></A>
<A HREF="submit.php"><IMG SRC="submit.jpg"></A>
<A HREF="upload.php"><IMG SRC="upload.jpg"></A>
</FORM>
I want to be able to POST the contents of those INPUT objects to either preview.php, clear.php, submit.php or upload.php, depending on the user's requirements. However, with only 1 URL able to be given for the form's ACTION parameter, and with the INPUT objects containing text too large to simply be transferred through the URL via the usual url.pjp?text=hello&text2=goodbye, how do I post the information to those different URLs depending on what button the user clicks on?

It seems quite a conundrum for quite a basic need.

Many thanks

Mark

Posted: Sun Mar 21, 2004 6:58 pm
by mjseaden
Those JPGs are button pictures for the links by the way - image buttons.

Posted: Mon Mar 22, 2004 8:33 am
by Bill H
You have posted three separate times on the same subject, which is not very polite. Nonetheless:

Item one. This creates a "submit" button using an image. A form may have as many as you like, each with a different "Name" property. Image can be a jpeg.

Code: Select all

&lt;INPUT TYPE=image src="ab_add.gif" Name="Page1"&gt;
A click on that button/image will result in a POST var in the resolving form of Page1.x and Page1.y which PHP resolves to Page1_x and Page1_y, so:

Code: Select all

<?php
if (isset($_POST['Page1_x']))
{     header("Location:Page1.html");   // or whatever
      exit;
}                    // repeat for each button/page conbination
?>

Posted: Mon Mar 22, 2004 8:36 am
by mjseaden
Hi - sorry about the multiple entries. I normally assume that if an item gets more than 10 rows down the line, it will be forgotten. Additionally to this, I reworded my explanation to that it was clearer what I was talking about.

Sorry for any inconvenience and thanks for the help.

Posted: Mon Mar 22, 2004 8:26 pm
by Bill H
From your other thread:
Thanks everyone, I managed to sort it using JavaScript functions.
Where does that leave people viewing your site who have JavaScript turned off in their browser due to security concerns?

Posted: Mon Mar 22, 2004 8:39 pm
by Sevengraff
if you redirect using header(), is the POST data sent along also?

I had this problem once before. I think I solved it like this:

Code: Select all

<form method="post" action="default.html">
<input> ...
<input type="submit" value="Click for normal action">
<input type="submit" value="go somewhere else" onClick="form.action='different.html';form.submit();">

Thank you for the _POST example

Posted: Tue May 11, 2004 2:29 pm
by thrdnttkn
<?php
if (isset($_POST['BuyNow_x']))

I have been struggling for days with this!

Thank you!!!!!!!!!!!!!!!!!