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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

web page form results needed

Status
Not open for further replies.

EDHills

Programmer
Jan 24, 2007
35
US
I've been programming in PHP for about a year, and this problem, for me, is very tricky

I have existing code which has a button, that, if pressed, causes a reservation to be made in the database.

I'm trying to add support for credit card deposit for the reservation.

Separate from the main application, I created a form which took the credit card info and submitted it to the merchant account for authorization and uses PHP to generate the results page which shows the results of the credit card authorization.

I'm not trying to integrate the two pieces of code together and am finding it hard to get the results back to the code that invoked the credit card collecting form in the first place.

Ideally, I want code like this

if ( $this->Place_Deposit($inputs) ) {
DoCodeNeededForConfirmedDeposit()
}

The problem is essentially this. How do I get the results of the form/ credit card confirmation back to the code that called the Place_Deposit function which creates the form for entering the credit card data? Right now, as soon as the Place_Deposit() function is run, there’s no wait for the results and get the results back from the collected results like there is in Windows programming.

I hope this is a dumb question and it's obvious to someone here, cause I've been searching/digging for a while.

thank you in advance for any input


 
you can return a result from the constructor of placeDeposit, but i am not a fan of that

Code:
class placeDeposit{

public function __construct($data){
 if ($this->doDeposit($data){
   return true;
} else {
 return false;
}
public function doDeposit(){
 //do some processing
}
}

i prefer that class constructors do not themselves return anything other than an instance of themselves.  

so i prefer to do this in my main code

[code=reservationProcessing]
//assume reservation is validated
//take deposit
$deposit = new takeDeposit();
$deposit->process();
if ($deposit->taken()){
 //show thankyou page
} elseif ( $deposit->cardRefused()){
 //show problem page
} elseif($deposit->noData()){
 $deposit->showCardForm();
} else {
 //do some default action
}

you could equally have a ->status() method that you query and use a switch statement to take the user off to the right function after.

the other way of achieving this goal is to use session variables. use the placeDeposit object to store a session marker than you can then check in your reservation page to inform you of what the deposit status is. Whilst this 'works' i do not think it is as good a solution as the proper integration method.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top