Page 1 of 1

murder- how 2call an HTML page, and wait until it completed?

Posted: Fri Jan 19, 2007 1:07 pm
by jeffery1493
Hi All,

All I have been trying to do for days is figure out how to get this line to call a second PHP program, and have the first PHP program wait until it has finished before proceeding on: :x :cry: :oops:

------------------------------------
(first PHP program)
echo"<script>location.href='paymentconfirm." .$phpEx."?secure=" . $post_id . "';</script>";
------------------------------------


The problem is, after running this line, PHP keeps going. The program is a PHP posting routine, just like the one you use here when you post a question, but when you click "POST" it takes you to a pay screen where you should pay to post a question.

The problem is now, once you click POST, stupid PHP continues ahead in program 1, posting the question whether or not you have paid.......impossible.

Going insane............thanks for any help or advice,

JEFFERY1493

Posted: Fri Jan 19, 2007 1:26 pm
by Kieran Huggins
whaaaa??????

can you explain what you're actually trying to accomplish?

Posted: Fri Jan 19, 2007 2:01 pm
by jeffery1493
I'm trying to accomplish a program that operates just like this one (you are using right now, in PHPBB). When you click "New Topic", you see a screen where you enter a topic.
At the bottom of the screen, there is the button, 'Submit'.


In my program, when you click Submit, you are then taken to a pay screen where you pay, via PayPal, to post the topic. The pay screen is another PHP program/routine called by the echo line above.

When you are done paying, it should continue the program at the line after 'echo.............', return you the Forum Index, where you will see the topic posted, or, if you did not pay, there should be no topic posted.

Posted: Fri Jan 19, 2007 2:08 pm
by jeffery1493
A deceptively simple idea, like a "GOSUB" in BASIC, and yet, in PHP, maddeningly complex........perhaps, impossible.

Posted: Fri Jan 19, 2007 2:23 pm
by jeffery1493
In my dreams (screen goes fuzzy):

----------------------------

(line 1)
(line 2)

$result = system (`echo"<script>location.href='paymentconfirm." .$phpEx."?secure=" . $post_id . "';</script>";` );

if ( $result == 1 ) // Payment succeeded
{
echo "Your topic has posted!";

(line 3)
(line 4)
(.........post the topic)
......
}

else
{
echo "Sorry, your payment did not go through.";
exit;
}
-----------------------------


Of course, that doesn't work..........

Posted: Fri Jan 19, 2007 4:19 pm
by aaronhall
Have you tried

Code: Select all

header('Location: http://www.mysite.com/somepage.php?foo=bar');
You cannot call this after output has been sent to the browser (this includes whitespace)

Posted: Fri Jan 19, 2007 4:23 pm
by aaronhall
Actually, after looking at your script again, what does payment confirm return? It doesn't look like this is set up securely. If you could describe the payment process, what paymentconfirm.php returns, etc., we can help you set this up a little better. Until then, I think you're looking for file_get_contents(), though this probably isn't the best way to go.

Posted: Sat Jan 20, 2007 6:58 pm
by jeffery1493
You hit the nail on the head. I am concerned about security too.

However, I can say specifically that the payment routine being called is PayPal. If you sign up with PayPal as a business or premier account, they will give you a hyperlink to their secured payment site for an online business so you can tie it to your website. You pass them basically just an amount variable and your PayPal account ID, and they handle the rest. That's why they get those big transaction fees (30c on a dollar). The PayPal MOD routine for PHPBB is already written to do this by itself and works, by someone else who can't be contacted.


All I need to do is exec this routine that calls PayPal and get back a SUCCESS or FAILURE.
Then get the posting program, posting.php, to sit and wait at this spot where the payment routine was called, and either continue on and post the topic if it is a SUCCESS, or abort the program if it is a failure.
It's the exact same posting.php program that is powering this site we are using now.

There are always possiblities.......and ways people can hack. Lots of other issues will probably have to be addressed.............. This is just one small hurdle of the puzzle I'm trying to figure out..........thanks

Posted: Sat Jan 20, 2007 7:25 pm
by aaronhall
If I remember correctly, PayPal will alert your server after a payment has been processed (I think by sending along the payment information to a script on your server).

If the user is compiling his post and THEN paying, you need to add the user's post to the database, and not display it publicly until you hear back from paypal that the payment was confirmed. You can easily do that by adding another field to the table like paymentConfirmed, and update that field to true once you hear back from paypal.

Don't settle for anything less than completely secure (or you'll pay for it).