post the variables to two pages?????

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hakiki_dolphin
Forum Newbie
Posts: 9
Joined: Thu Jan 30, 2003 3:00 pm

post the variables to two pages?????

Post by hakiki_dolphin »

Hi,
How can I post the variables to two php pages?
Ex: <form name="form" method="post" action='login1.php';'alogin1.php'>
.....
.....
<input type="submit" name="Submit" value="Tamam">


This code didn't work.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Why do you need to post the data to two pages?

Mac
superwormy
Forum Commoner
Posts: 67
Joined: Fri Oct 04, 2002 9:25 am
Location: CT

Post by superwormy »

You can't using strait X/HTML, but you could use fsockopen or that PostToHost function I keep seeing around to make the second post to the second page.

http://www.php.net/fsockopen
http://www.faqts.com/knowledge_base/vie ... 039/fid/51
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

You could also have "login1.php" auto-submit to "alogin1.php". Certainly not the most elegant solution, but it's definitely workable.
User avatar
BigE
Site Admin
Posts: 139
Joined: Fri Apr 19, 2002 9:49 am
Location: Missouri, USA
Contact:

Post by BigE »

Yeah, your most likely going to have to use PHP to code that for you. HTML can only submit to one page at a time that I'm aware of.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

I don't know if that works, but you can bubble the onSubmit-event in Javascript.

If you look at the code below, you'll notice

a) document.form1.target - same as target in an <a href>. Thus you can easily use it to submit into invisible frames)
b) document.form1.action - which basically allows you to dynamically change the <form action="fileblabla.php"> tag.

Code: Select all

<script language=javascript>
function submitForm(path)
&#123;
	if (path=="whatever.php") 
		document.form1.target="_blank";
	else document.form1.target="_self";
	document.form1.action=path;
	document.form1.submit();
&#125;
</script>

<FORM name="form1" action="submit_to_wherever.php" method="post" onSubmit="return false;">
bla bla form bla bla
<input type=button onClick="submitForm('submit_form.php');"  value='Submit Form'>
Post Reply