By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,637 Members | 2,825 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,637 IT Pros & Developers. It's quick & easy.

HTML Form validating with PHP, processing via ASP?

clintw
P: 10
My problem.

I have a html contact form that is being spammed. So I have set .html to be treated as .php, in order to include php image verification into the form. However, the Action on the form originally directed to an .asp file on a remote server, which updates a database and sends a copy of the form via mail.(For various reasons, the remote server with its ASP script must do the form processing). To use the image verification, the form actions on itself. Is it possible to validate with PHP and then finally POST again to a second remote URL that uses ASP to process the contents of the submission, or is that not possible? I read somewhere, when you redirect using Location, the values of a POST are included, so would that be treated as an actual POST by the destination url if its a .asp script? I haven't dealt with ASP, so wouldn't know how to implement image verification to handle the submission completely in ASP. Any help or suggestions welcomed. Thanks
Feb 2 '07 #1
Share this Question
Share on Google+
3 Replies


Motoma
Expert 2.5K+
P: 3,235
My problem.

I have a html contact form that is being spammed. So I have set .html to be treated as .php, in order to include php image verification into the form. However, the Action on the form originally directed to an .asp file on a remote server, which updates a database and sends a copy of the form via mail.(For various reasons, the remote server with its ASP script must do the form processing). To use the image verification, the form actions on itself. Is it possible to validate with PHP and then finally POST again to a second remote URL that uses ASP to process the contents of the submission, or is that not possible? I read somewhere, when you redirect using Location, the values of a POST are included, so would that be treated as an actual POST by the destination url if its a .asp script? I haven't dealt with ASP, so wouldn't know how to implement image verification to handle the submission completely in ASP. Any help or suggestions welcomed. Thanks
Welcome to The Scripts, clintw.
I don't believe you can POST by using a Location call.
What you can do, however, is generate a form with PHP, and then have javascript immediately submit the form using an onload.
Feb 2 '07 #2

ronverdonk
Expert 2.5K+
P: 4,258
But you can POST either via JavaScript (Ajax) or using cURL. For the latter I will show you 2 examples of how to achieve this.

The first example posts a string, just like you would do with an URL parm string.
The second example POSTs an array.

When you neeed m ore information on CURL, look at the PHP documentation at CURL documentation .

Example 1, POST a parameter string[php]<?php
//
// A very simple PHP example that sends a HTTP POST to a remote site
//

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"http://www.mysite.com/tester.phtml");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"postvar1=value1&postvar2=value2&postvar3=value3") ;
curl_exec ($ch);
curl_close ($ch);
?>[/php]
Example 2, POST an array[php]<?php
// ------------ POST an array via curl -----------------------

// create a new curl resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://path/to/your/page.php");
$id=111; $code='ABCD';

// Build the test array
$data=array( 'id'=>$id, 'code'=>'$code');

// Do a POST
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

// grab URL, and print
curl_exec($ch);

?>[/php]
Ronald :cool:
Feb 2 '07 #3

clintw
P: 10
Hi, thanks for the replies. Will definitely give these suggestions a try and post a followup.
Feb 5 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.