Page 1 of 1

[Solved] Need help with POSTing problem

Posted: Mon Mar 22, 2004 5:43 am
by mjseaden
Dear All

The following is a basic summary of code I am currently using in a data form. The links (preview.php, clear.php, submit.php, upload.php) are image buttons pointing to those prospective URLs. Each of these pages (preview.php, clear.php, submit.php, upload.php) needs to receive the contents of the INPUT objects within the FORM below in order to carry out processing.

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>
Normally this information is posted to an URL via a SUBMIT button, whereupon the browser is redirected to the single URL given in the ACTION parameter for the form.

However, with only 1 URL able to be given for the form's ACTION parameter (I have left this as ?????.php as I don't know what to put), and with the INPUT objects containing text too large to simply be transferred through the URL via the usual e.g. url.php?text=hello&text2=goodbye, how do I post the information to <I>multiple</I> different URLs, depending on what button the user clicks on?

If it is not possible this way, is it possible any other way?

Many thanks

Mark

Posted: Mon Mar 22, 2004 6:50 am
by patrikG
One form can only submit to one page. Change your code so that that one page does everything you need.

Posted: Mon Mar 22, 2004 7:09 am
by tim
ie:

Code: Select all

&lt;form action="page.php?text=$text&amp;username=$username method=POST&gt;

Code: Select all

<?php
if (isset($text)) {
//do something
}

if (isset($username)) {
// do something
}
etc
?>

Posted: Mon Mar 22, 2004 7:34 am
by coreycollins
Actually, not to come down on ya again tim but the action that you're showing is more the result of a get not a post. The difference between a get and a post is a get puts the results up in the url and a post does not. It does not matter whether you are going to a different page or the same page. With that said, the code should be:

Code: Select all

&lt;form action="page.php" method=POST&gt;
Then

Code: Select all

<?php
if (isset($_POST["text"])) {
//do something
}

if (isset($_POST["username"])) {
// do something
}
etc
?>

Posted: Mon Mar 22, 2004 7:37 am
by mjseaden
You've assumed I would be able to set a variable when the user clicks a button. That would require JavaScript wouldn't it?

I can't set text or username upon a user pressing a button, that requires realtime clientside code. I think that's the only way to do it.

Posted: Mon Mar 22, 2004 8:23 am
by magicrobotmonkey
Yea you would need to use javascript for this. I do it with a hidden for field that each button changes the value of before it submits. Then php checks the $_POST variable and acts accordingly

Posted: Mon Mar 22, 2004 8:35 am
by mjseaden
Thanks everyone, I managed to sort it using JavaScript functions.

Posted: Mon Mar 22, 2004 8:38 am
by Bill H
Which is why we don't like multiple posts. I just wasted time providing you with a solution (a simpler one than javascript, by the way) in one of your two other threads on this subject.

Try to limit yourself to one thread on one subject.
:twisted: :evil:

Posted: Mon Mar 22, 2004 8:39 am
by mjseaden
Sorry Bill, please read the previous thread which I responded to.

Posted: Mon Mar 22, 2004 8:43 am
by patrikG
mjseaden: We are all volunteers here and Bill H's anger is very understandable. You've wasted his (and other people's) time for no reason.

one problem = one thread!

Posted: Mon Mar 22, 2004 8:44 am
by m3mn0n
I concur. :wink:

Posted: Mon Mar 22, 2004 8:45 am
by patrikG
As do I :lol:

Posted: Mon Mar 22, 2004 8:49 am
by mjseaden
Okay, okay, one of them was posted around 2am in the morning my time because I am trying to make the most of whatever time I have at the moment. Someone trailed down the list and posted a reply to that thread soon before/after I posted the other one - something that could happen to anyone.

Not that that's an excuse, but lay off a bit - I really don't usually try and muck up forums with multiple threads, and I do appreciate that everyone is a volunteer here.

Mark

Posted: Mon Mar 22, 2004 8:51 am
by patrikG
Easiest solution if you haven't received a reply to a post you've made: post your own reply consisting of a simple:

"'/bump"

Simple.