Forum Moderators: coopster

Message Too Old, No Replies

PHP and forms

a novice question

         

Algebrator

3:41 pm on Nov 7, 2003 (gmt 0)

10+ Year Member



This is probably a silly question, but please bear with me; this is the first time I am using PHP

I have a new merchant account, and I need to submit data to my CC processor via an html form. Right now, there are no input fields on it (only some hidden ones) because I chose for the customer to fill out all their info at the CC processor site

This merchant processor also accepts echecks and I also accept paypal . Action url for check and CC is different (and of course the html code is totally different for the paypal). What I would like to do, via php, is to generate diferent html code based on the checkmark checked by the user and submit it.

I understand how to generate the php page with the correct html code, but what I still need is automatic "submit" action - equivalent of submit button action, but not having the user click on anything.

Any help is greatly appreciated

Thanks

lorax

5:00 pm on Nov 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I think it would be easier to use a combination of Javascript Timer and the this.form.submit() function.

coopster

7:18 pm on Nov 7, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Are you saying you want your PHP code to perform the form submittal (POST) for you to the processor after the user has chosen a payment method? Have you had a look at the PHP HTTP functions [us3.php.net]? The User Contributed notes may have a sample of how to POST data using these functions.

Algebrator

11:29 pm on Nov 7, 2003 (gmt 0)

10+ Year Member



Lorax,
Thanks, it might be that Javascript this.form.submit() is what I am looking for, although I am not sure how (or why) would Timer would be useful here

Coopster,
Yes that is what I was trying to say ... I will look at the examples that you were referring to
Thanks

Ultimately it doesn't matter to me whether it is PHP or Javascript or something else as long as it does the job

Birdman

11:56 pm on Nov 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think what you want is the PHP header() [php.net] function.

Submit your form to your PHP script and then use a simple if-else to go to the correct location.

Example:


<?php
if ($paymentprocessor == "PayPal")
{
header("Location: h^tp://www.paypal.com/your/formatted/link/here");
} else {
header("Location: h^tp://www.otherguy.com/your/formatted/link/here");
}
?>

Hope that helps out.

Birdman

lorax

4:42 am on Nov 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Re: timer - sorry I was in between two thoughts. I was thinking of using the onLoad function and intiating a timer to allow the rest of the page to load before the form.submit() was executed otherwise you could end up with only part of the form being submitted.

dcrombie

4:53 pm on Nov 8, 2003 (gmt 0)



Using JS to submit a form without the user clicking on something will generate an alert in most browsers. Too many people were combining form.submit() with method="mailto:..." to grab visitors email addresses...

lorax

3:59 am on Nov 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Good point dcrombie.