Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Run More Than 1 Action in a Form?

Status
Not open for further replies.

jswannabe

Programmer
Aug 10, 2007
8
US
Hi,

I am quite the rookie with PHP and really need some help. I have what was a .html page with a form for potential clients to fill out. The site is hosted at Yahoo! and requires that I use the following to process the form:

Code:
<form method=post action="[URL unfurl="true"]http://us.1.p.geocities.yahoo.com/forms?login=mylogin@sbcglobal.net">[/URL]

In order to discourage spam, I am turning this into a .php page and using a captcha that I found online. I have had to change the form tag to do this first:

Code:
<form method="POST" action="<?php echo $SERVER['SCRIPT_URL']?>">

The problem for me is that once the code determines the user entered the appropriate code, now I need to send the form off to yahoo to process - but I don't know how to. I am used to directing the form processing through the action= in the form tag. I don't know how to call it in the middle of this php code:


Code:
<?php
if ($_POST['send']) {
	$errors = array();
	if ($_POST['captcha'] != $_SESSION['captchacode']) {
		$errors[] = "You did not enter the letters shown in the image.";
	} 
	if (!count($errors)) {
		// IMPORTANT: If you don't call this the 
		// user will keep getting the SAME code!
		captchaDone();
		echo "<form action="$jewel" method="POST"< ";
		$message = $_POST['message'];
		//ACTION TO GO TO YAHOO FORM PROCESSING SHOULD GO HERE
		
?>

Any help is extremely appreciated!
 
The problem is that the form is now already processed. By you. You have the data now and can process it. The data is in the $_POST superglobal. If you don't need the geocities page, you can now process what was sent.

But if you do want to send the data to the geocities page, you will have to "open a new browser from the server". You don't really open a windowed browser, but what you use is curl. Curl is a library that mimics a browser and in effect is one, but one to be used from code or the command-line. But really think of it as a separate browser. So if you get a redirect from the geocities page (to a "thank you" page, for instance, your "curl browser" receives that redirection and the visitor to your website won't see any of it unless you take the trouble of sending that redirect to the visitor's client.

Curl is a very versatile library with a lot of options, so I suggest you read its manual (see ). Check if curl is enabled on the yahoo servers first, using the php_info() function. Don't leave that function open to the world after you have used it.

Good luck!


+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top