POSTing the same data to two different pages

Apr 25, 2004
44
0
0

Posted November 23, 2005 17:18 Reply With QuoteEdit or Delete Message
Keeping it simple...

<form method="post" action="sendmail.php">
Name:<input name="name" type="text" class="input-box" />
<input type="submit" value="Submit" class="submit-button" />
</form>



sendmail.php looks like

<?php
$name = $_REQUEST['name'] ;
mail( "name@server.com", "Subject","$name submited a form",$headers);
?>




So now I need to take $name and POST it to server2.com/sendmail2.php. We can assume that the name field is the same in their original form. The idea is to save the user from entering the SAME data in two forms.

I can live with a PHP script that simply loads the $variables as the values into another form. In other words, they click submit and it does its job and then fills another page's form's values with the variables. This way they just click submit again and the data is then sent off to the other script.

Also, I tried using PEAR but Dreamhost does not support this.
 

GeekDrew

Diamond Member
Jun 7, 2000
9,099
19
81
Out of curiosity, why are you needing to post this to two different places at once? That's extremely unreliable, as I would not count on users always submitting them to both forums - I'd bet that it'll be submitted to one form or the other. I hope you're not trying to maintain consistent data or anything.
 

Modeps

Lifer
Oct 24, 2000
17,254
44
91
You could do it dirty like and create a hidden form already populated with the values you submit... then submit that form with javascript.

So:
Original Form (submit)-> Mail Form on Server 1 w/ Hidden Form (submit)-> Mail Form on Server 2
 

rmrf

Platinum Member
May 14, 2003
2,872
0
0
Originally posted by: Modeps
You could do it dirty like and create a hidden form already populated with the values you submit... then submit that form with javascript.

So:
Original Form (submit)-> Mail Form on Server 1 w/ Hidden Form (submit)-> Mail Form on Server 2

why not just do it the easy way and use sessions? it's really not hard at all to implement, and it works perfect for what he wants to do.

a monkey could follow the guide that I posted.
 

GeekDrew

Diamond Member
Jun 7, 2000
9,099
19
81
Originally posted by: rmrf
Originally posted by: Modeps
You could do it dirty like and create a hidden form already populated with the values you submit... then submit that form with javascript.

So:
Original Form (submit)-> Mail Form on Server 1 w/ Hidden Form (submit)-> Mail Form on Server 2

why not just do it the easy way and use sessions? it's really not hard at all to implement, and it works perfect for what he wants to do.

a monkey could follow the guide that I posted.

How do sessions help his situation at all?
 
Apr 25, 2004
44
0
0
Sessions don't help at all. Why am I doing this? Im obviously making a paypal fishing site called paypa1.com. Users post their login information to me and then I sign them in and they are NONE THE WISER.

OR instead of asking a silly question you might want to devote those brain cells to figuring this one out. Eh? What does it matter what its for. Its so I can save a step for the user so s/he doesn't have to put the same info in twice nor leave our site. But that has nothing to do with anything.
 
Apr 25, 2004
44
0
0
Originally posted by: Modeps
You could do it dirty like and create a hidden form already populated with the values you submit... then submit that form with javascript.

So:
Original Form (submit)-> Mail Form on Server 1 w/ Hidden Form (submit)-> Mail Form on Server 2

This is actually the dirty work around I have now. I just need to look up the JS to have something submit automatically. I actually have to do that in an iframe because once submited it takes them to another page and thats some of the mess I wanted to avoid.
 

GeekDrew

Diamond Member
Jun 7, 2000
9,099
19
81
Originally posted by: rosewood
Sessions don't help at all. Why am I doing this? Im obviously making a paypal fishing site called paypa1.com. Users post their login information to me and then I sign them in and they are NONE THE WISER.

OR instead of asking a silly question you might want to devote those brain cells to figuring this one out. Eh? What does it matter what its for. Its so I can save a step for the user so s/he doesn't have to put the same info in twice nor leave our site. But that has nothing to do with anything.

Sorry, asking 'why' is not a "silly question". The reason I asked is because I have seen many people do things like this (and in all of the cases thus far, it's been stupid to do so IMHO), when it would be simpler to just do something in the background with the information, since it's always going to be submitted twice. But hey, you don't have to share your logic. Enjoy.
 
Apr 25, 2004
44
0
0
No. Its more of a stupid forum mentality. No need to just get to the point and answer the question. Instead people love to rip apart the basic question and change things. Its like when someone says "Whats a good Xbox game?" and you get a reply like "Katamari for the PS2 is much better then ..." What the hell does that have to do with the question? Nothing. Well, asking WHY is just as silly. It has nothing to do with what the end goal is. I know, I know. Everyone is an expert and can do it better. I always forget that about forums.
 

GeekDrew

Diamond Member
Jun 7, 2000
9,099
19
81
Originally posted by: rosewood
No. Its more of a stupid forum mentality. No need to just get to the point and answer the question. Instead people love to rip apart the basic question and change things. Its like when someone says "Whats a good Xbox game?" and you get a reply like "Katamari for the PS2 is much better then ..." What the hell does that have to do with the question? Nothing. Well, asking WHY is just as silly. It has nothing to do with what the end goal is. I know, I know. Everyone is an expert and can do it better. I always forget that about forums.

No, someone responding about the PS2 when asked about Xbox is not even a remote comparison to me asking why you might want to be doing something.

It's *not* just as silly. Most of the time, there *is* a better (yes, I know that better is subjective) way to do something, when someone has to ask how to do something that isn't easily covered in documentation all over the web. This may or may not be one of those cases.

I liken it more toward someone asking "what's the easiest way to siphon fuel out of a car?" I'm going to ask them *why*, because I do not want to give them a useful answer that could help them siphon fuel out of John Doe's vehicles. However, if they provide any opposing explanation whatsoever, I have reasonable doubt, and will answer them, trusting that they are not going to be siphoning everyone's fuel. It's much the same principal. I'm not going to help you submit one form to multiple places via the end user, because of security concerns - I can't think of any reason why you would need to do that, off of the top of my head. But I can think of plenty of reasons why you would not want to do that. Say, if John Q User typed his credit card information into an online form, he would probably not want it to be submitted to multiple locations, especially if they are unsecure, and even moreso if there is no up-front reasoning behind it.

<sigh> But I'm rambling now. It's your choice. You can always find help elsewhere, or perhaps another kind soul here at Anandtech will help you out.
 

NikPreviousAcct

No Lifer
Aug 15, 2000
52,763
1
0
Calm down gentlemen. It's just a forum on the internet.

Rosewood, you're new here. If you're not willing to work with folks here, then folks here won't be as willing to work with you in the future. Is it that hard to answer the question as opposed to taking several posts and MANY more words to avoid the question?

Drew, don't bother with someone who's willing to go out of their way to not answer the question. Let him figure it out for himself then.
 
Apr 25, 2004
44
0
0
Okay so first you say that you asked "why" because you thought if you knew "why" then you might find a better solution. Now you say you asked because of security concerns! You can't even get your story straight. So to that I have to say Sorry! I didn't realize you were Mr. Internet Police. (Your example is pretty weak sauce because any time secure information is being posted, you are doing it over HTTPS and any cross posting for HTTPS will generate warnings ... even in IE.)

If you can't think of a reason why someone would only want to enter data ONCE then you aren't thinking very hard. Sure it can be used for bad things but so can possitioning in CSS! When someone asks how to possition an element do you ask them WHY because they might possition something over a security warning? Of course not. You get to answering the question or you just ignore the thread and move on. If you thought I was up to something fishy and you really REALLY had to get your $.02 in ... why did you do it in such a round about way? Why not just come out and say it?

My comparison still holds because your commentary has NOTHING to do with the question. Its what one would call a thread hijack. Oh sure, I like the free bumps but come on now.
 
Apr 25, 2004
44
0
0
Originally posted by: Nik
Calm down gentlemen. It's just a forum on the internet.

Rosewood, you're new here. If you're not willing to work with folks here, then folks here won't be as willing to work with you in the future. Is it that hard to answer the question as opposed to taking several posts and MANY more words to avoid the question?

Drew, don't bother with someone who's willing to go out of their way to not answer the question. Let him figure it out for himself then.

Who said I am anything but calm? I forget that to some of you FORUMS: SERIOUS BUSINESS. I am anything but new here. However, attitudes like this keep me lurking 99.9% of the time. Lurking to the point that my account got purged. Anand and the K6 reviews got me to his site YEARS ago. As for answering the question ... wow man. And you say I am new here.

Originally posted by: rosewood
Its so I can save a step for the user so s/he doesn't have to put the same info in twice nor leave our site. But that has nothing to do with anything.

But even after I answer the question he wants to go on and on and on and on instead of just answering my original question.
 

GeekDrew

Diamond Member
Jun 7, 2000
9,099
19
81
Originally posted by: rosewood
(Your example is pretty weak sauce because any time secure information is being posted, you are doing it over HTTPS and any cross posting for HTTPS will generate warnings ... even in IE.)

Except that John Q Consumer doesn't actually read warnings, he just clicks 'OK'.

If you can't think of a reason why someone would only want to enter data ONCE then you aren't thinking very hard. Sure it can be used for bad things but so can possitioning in CSS! When someone asks how to possition an element do you ask them WHY because they might possition something over a security warning? Of course not. You get to answering the question or you just ignore the thread and move on. If you thought I was up to something fishy and you really REALLY had to get your $.02 in ... why did you do it in such a round about way? Why not just come out and say it?

I'm not saying that you in particular are doing anything dishonorable. I'm simply saying that I distrust the average forum poster, and this thread just made me more cautious than most, due to what can be done with it.

Oh, and in regards to CSS positioning: that actually isn't a very big security risk, because browsers will present their own error messages on top of whatever the site is requesting, not that they matter, since the average person doesn't really read them, in my experience. CSS is presentation, not functionality. Posting data is functionality, not presentation.

My comparison still holds because your commentary has NOTHING to do with the question. Its what one would call a thread hijack. Oh sure, I like the free bumps but come on now.

<shrug> I had no intent to hijack this thread. I know that I've pissed off the random member here and there, but I like to think that I'm rather well respected, given some of the comments I've made on the forums. But that's neither here nor there. Hold onto your comparison all you like. I disagree with you. No, it doesn't really matter that I disagree, since I'm just another forum member, but it seems as though you're trying to prove me wrong. ;)
 
Apr 25, 2004
44
0
0
It still has nothing to do with anything. You could just admit that I answered the question straight away and you have to act like it still had anything to do with anything. And even when you want to continue this pointless discussion, you can't even address the fact that you aren't even being straight about your motives.

I also like the "oh look at me, Im known around here" attn bit there. If it is neither here nor there ... why bring it up? Oh, because you want yet another thing to be about YOU. Thats why you can't just let this thread be about answering the original question. You have to drag yourself into yet another thread where you don't belong.

Its a shame I can't just lock this thread and let it die. Next best thing is just unsubscribing and going back to the ocational lurk. Im desperate to get this done but obviously the members of the anandtech forums these days are more focused on creating forum drama (for what pathetic drama it is) then actually answering OP questions.
 

NikPreviousAcct

No Lifer
Aug 15, 2000
52,763
1
0
If you want the thread to die, why do you keep responding? YOU were the one that made a big stink about it instead of just answering the question so he could help you.
 
Apr 25, 2004
44
0
0
Originally posted by: Nik
If you want the thread to die, why do you keep responding? YOU were the one that made a big stink about it instead of just answering the question so he could help you.

I will let it die but luckily for me, I still got a notification of your reply. I was serious about letting it die but you had to come in with the "instead of just answering the question."

You would think with 49269 posts you would have learned how to read. You would think that even when someone quotes it for you and shows it to you again you would have picked up on it. Let me spell it out for you again...

I did answer his worthless question. Is it too much that someone answer mine?
Also, he didn't ask it to help me. Oh sure, thats what he said at first. Then he changed his story to that BS about security.

Actually, I'll go ahead and stay subscribed. I've changed my mind. Its just too much commedy gold for me to let go.
 
Apr 25, 2004
44
0
0
Originally posted by: Modeps
You could do it dirty like and create a hidden form already populated with the values you submit... then submit that form with javascript.

So:
Original Form (submit)-> Mail Form on Server 1 w/ Hidden Form (submit)-> Mail Form on Server 2

Im having trouble hiding the 2nd form. Any tips?
 

rmrf

Platinum Member
May 14, 2003
2,872
0
0
Sorry to bring this thread up again.

I didn't realize the OP wanted to have a user post information to website #1, and have website #1 automatically post that info to website #2.

Why wouldn't you just make a redirect from server #1 to server #2, and have them enter the info into the end result? I won't go into why you would do it, but I have a feeling it's not on the "up and up".
 

Modeps

Lifer
Oct 24, 2000
17,254
44
91
I dont understand why everyone is automatically assuming it's not a legit use. He posted a web programming question, lets help him figure it out.

Alright, it could get tricky if you want to hide the second form, but an iFrame would probably be your best bet. Send the user inputted variables to the iframe using the url string when calling the iframe source, then in that iframe page write out the form on the server side and that's where you can fire off the javascript (from the user side) to submit THAT iframe form.

your iframe code should look something like this:
<iframe src="hiddenpost.php?uservar1=X&uservar2=X&uservar3=X"></iframe>

So in the end the process would flow
Original Form (submit)-> Mail Form on Server 1 with iFrame -> Hidden PHP page (submit)-> Mail Form on Server 2
 

tfinch2

Lifer
Feb 3, 2004
22,114
1
0
Originally posted by: rosewood
Originally posted by: Modeps
You could do it dirty like and create a hidden form already populated with the values you submit... then submit that form with javascript.

So:
Original Form (submit)-> Mail Form on Server 1 w/ Hidden Form (submit)-> Mail Form on Server 2

Im having trouble hiding the 2nd form. Any tips?

Form heading...

<form method="post" action="blahscript.php" class="hidden">

Add to your style sheet...

.hidden
{
display: none;
}
 

rmrf

Platinum Member
May 14, 2003
2,872
0
0
Originally posted by: Modeps
I dont understand why everyone is automatically assuming it's not a legit use. He posted a web programming question, lets help him figure it out.

Alright, it could get tricky if you want to hide the second form, but an iFrame would probably be your best bet. Send the user inputted variables to the iframe using the url string when calling the iframe source, then in that iframe page write out the form on the server side and that's where you can fire off the javascript (from the user side) to submit THAT iframe form.

your iframe code should look something like this:
<iframe src="hiddenpost.php?uservar1=X&uservar2=X&uservar3=X"></iframe>

So in the end the process would flow
Original Form (submit)-> Mail Form on Server 1 with iFrame -> Hidden PHP page (submit)-> Mail Form on Server 2

it seems shady to me, because why would he want people to enter info on his site, to be entered in a site he doesn't own?

if he owned the site, there wouldn't be any difficulty to putting this info in another form on server2, because he would just have to use mysql to recall the info entered. plus the fact that he is not willing AT ALL to tell us why he would need to do something like this.
 
Apr 25, 2004
44
0
0
Originally posted by: rmrf
Sorry to bring this thread up again.

Wow ... just ... wow. Did you not even bother to read the thread before posting such trash again?

I actually got it figured out using my original PEAR script that I should have pasted here. I didn't realize that in PHP "require" is a way to load modules and that Request.php was a PEAR module that Dreamhost didn't have. So, I downloaded Request.php, pointed to ./Request.php, editied ./Request.php so that it knew URL.php was ./URL.php after I downloaded that ah heck as well. Voila.

The only thing that bugs me now is that their page gives the same results if you fill in the form right, if you forget to fill it in or partially fill it in. So, I have no way of doing an error check. Oh well, should all go.


Originally posted by: tfinch2
Originally posted by: rosewood
Originally posted by: Modeps
You could do it dirty like and create a hidden form already populated with the values you submit... then submit that form with javascript.
So:
Original Form (submit)-> Mail Form on Server 1 w/ Hidden Form (submit)-> Mail Form on Server 2
Im having trouble hiding the 2nd form. Any tips?

Form heading...
<form method="post" action="blahscript.php" class="hidden">
Add to your style sheet...
.hidden
{
display: none;
}

Blargh. Display none. Completely forgot about that. I'll tuck that away for future things I'll forget.

Originally posted by: rmrf
Originally posted by: Modeps
I dont understand why everyone is automatically assuming it's not a legit use. He posted a web programming question, lets help him figure it out.
Alright, it could get tricky if you want to hide the second form, but an iFrame would probably be your best bet. Send the user inputted variables to the iframe using the url string when calling the iframe source, then in that iframe page write out the form on the server side and that's where you can fire off the javascript (from the user side) to submit THAT iframe form.
your iframe code should look something like this:
<iframe src="hiddenpost.php?uservar1=X&uservar2=X&uservar3=X"></iframe>
So in the end the process would flow
Original Form (submit)-> Mail Form on Server 1 with iFrame -> Hidden PHP page (submit)-> Mail Form on Server 2
it seems shady to me, because why would he want people to enter info on his site, to be entered in a site he doesn't own?
if he owned the site, there wouldn't be any difficulty to putting this info in another form on server2, because he would just have to use mysql to recall the info entered. plus the fact that he is not willing AT ALL to tell us why he would need to do something like this.

JESUS H CHRIST MAN! READ. THE. THREAD. Just ****** WOW.

Originally posted by: rosewood
[
Originally posted by: rosewood
Its so I can save a step for the user so s/he doesn't have to put the same info in twice nor leave our site. But that has nothing to do with anything.

Thats the third time in 1.5 pages I've had to say that. :Q What the hell is so hard to understand about that?