Jump to content

Recommended Posts

Per usual, I'm having an issue wrapping my head an issue, or I'm just not able to narrow the search well enough.

 

I have a form...

method = post

action = /process.php

Upon hitting process.php, it will UPDATE a data table with the $_POST data it gets from the form.

After that, I want to send it to PayPal.  

 

It seems like at some point I was able to complete two 'actions' at once, but it's so long since I've created my own forms.  Then again, maybe it was a redirect after executing the UPDATE.  I just don't remember, and anything I search for doesn't seem to produce results of something that worked.  

Link to comment
https://forums.phpfreaks.com/topic/308781-processing-a-form-and-redirecting/
Share on other sites

What "it" do you want to send to paypal?

Your form provides the input values; a query statement will save that data to the table.  Then what?  Send that very same data to paypal in some pre-defined format that Paypal has provided for you?  So - follow that format, create the proper string/array/??? that the paypal API has instructed you to do, and deliver it the way the API tells you to do.

  • Like 1

If you need to send the user to PayPal then you can't do it from PHP - it's something that needs to happen in the user's browser. The most obvious method would be to have your page show a sort of "processing" message, with the PayPal <form> that automatically (via Javascript) submits itself.

If you need to POST data to PayPal but the user doesn't matter then cURL is the answer: you do the work in your code.

  • Like 1

I apologize.  I do not need to send any data to PayPal.   

 

@requinix I figured it wouldn't be done via PHP.  If I sent to process.php and had a redirect once there, would it process the UPDATE before redirecting?  

 

(All of this because I have to dynamically create values in a dropbox, but that part I have figured out...just not the way to send the User to PayPal afterward as well.)

34 minutes ago, Jim R said:

I apologize.  I do not need to send any data to PayPal.

So... nevermind? No problems?

Quote

@requinix I figured it wouldn't be done via PHP.  If I sent to process.php and had a redirect once there, would it process the UPDATE before redirecting?  

If that's what you tell your code to do then that's what your code will do.

I am not sure what you are thinking as a "redirect".  Most of us may think that you are simply issuing a header("Location: $url)" command to take you to somewhere after having accomplished whatever you wanted to do before going to another script.

  • Like 1
3 hours ago, Jim R said:

I guess it's thinking too linear, that it would redirect before executing the UPDATE.  

The Chrome/Firefox dev tools are a great way to explore your understanding of these things.

Basically HTTP has a request/response format.

Client Makes Request to server ---->   Server receives Request (GET or POST)

Server processes request....

At this point your PHP code is running and can do whatever you want it to do. 

So if your goal is to redirect the user to a different page, then you have 2 ways to do that.  Either set a location header or use the html meta refresh.  

In the case of the location header, once anything was echo'd to the client, the http header will have already been sent and it will be too late.  Like session_start(), if you need to make header() calls, they have to come first.  Of course that doesn't mean that you can't have done processing, stored data, sent email or anything else you require first.  

 

  • Like 1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.