Computing.Net > Forums > Web Development > Open URLs in PHP w/out opening wind

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Open URLs in PHP w/out opening wind

Reply to Message Icon

Name: drsmartman
Date: March 23, 2004 at 13:03:54 Pacific
OS: RH Linux
CPU/Ram: NA
Comment:

hey all....

Okay, I need to submit a form for processing with
PHP. Upon submission of the form, the new page
needs to:

a.) Look at the submitted parameters (products) and
open a URL for each associated product to add it to
an off-site shopping cart. The URLs hit may be many
(say, 5) to add a number of products...however, this
page cannot be displayed...

b.) Display an invoice page with the products
purchased. I can do this easily. The page would then
have a link to "checkout".

Any idea how to do this? I could do it with JavaScript,
but would rather keep such code protected and on
the server-side.

Any ideas?

Many thanks!



Sponsored Link
Ads by Google

Response Number 1
Name: SN
Date: March 23, 2004 at 13:12:41 Pacific
Reply:

I'm sure there must be more elegant ways of doing this, but here are a few options:

1. Put the product/cart pages in frames of size 0, then have one frame with the invoice page (make sure checkout button has target="_top")

2. Have the PHP program open the product URLs for the client...This may or may not be possible, depending on whether all the necessary info is in the url. If the pages put cookies on the client's machine, this won't work. But assuming all the information is in the URL, you could simply do something like
file_get_contents("http://www.mycart.com?username=SN&productID=12");

Again, I'm sure other people will have more elegant solutions.

-SN


0

Response Number 2
Name: drsmartman
Date: March 23, 2004 at 15:37:39 Pacific
Reply:

Hey SN,

I tried your solution above to no avail. For testing, I
used the code below....

<?php

file_get_contents("http://
www.mycart.com?username=SN&productID=12");

////also used
fopen("http://
www.mycart.com?username=SN&productID=12","rb")
;

?>

go to
checkout

Unfortunately, when I went to the cart...nothing. I
accessed the URL manually, then brought up the
checkup link and it work. I also did this using
JavaScript and it worked (to some extent).

If the page was accessed, wouldn't a cookie still be
placed on the browser?

Anyway, any other ideas are much appreciated.

Many thanks,
DrS


0

Response Number 3
Name: SN
Date: March 23, 2004 at 16:24:50 Pacific
Reply:

DrS-
No...If going to the URL places a cookie on the user's computer, then the PHP way I mentioned won't work. This is because the server is the one making the request, and the shopping cart server doesn't even know of another client. I hoped that your shopping cart provider maintained a database of some kind and didn't rely on cookies...Not very probable, but it was worth a shot.

I don't know if it's possible to "copy" a cookie in PHP...It would definitely be interesting, but I'm not familiar enough with the process to know how it would work.

How are you doing it in Javascript? Maybe knowing your js solution would help in coming up with a more reasonable one.

What do you think of the frames idea? Doable?

-SN


0

Response Number 4
Name: drsmartman
Date: March 23, 2004 at 17:28:31 Pacific
Reply:

SN -

First, thanks for your continued contributions to
computing.net (and me especially, lol).

Second, back to business. No, they do not rely on
cookies and a database is maintained. The shopping
cart is through Bank of America....sound and secure.
We are using the shopping cart to circumvent
additional coding and maintainence of a secure
server with BOA's web services solution...however,
we lose some flexibility.

The Javascript solution was simple. Essentially, all I
did was use 'window.open()' on a blank window for
as many products as were needed. I would, however,
like to keep this code on the server-side if at all
possible.

For example, products 1, 4, 6 and 8 were purchased
(or, filled out in the form, to be accurate).
onSubmit(), a Javascript function sees the selected
products and opens links to products 1,4,6 and
8....adding each to the cart. When the function is
done, bring up the checkout link (off site). Now, all
the products are in the shopping cart and ready for
checkout.

Can this be done in the header? Somewhere else? You are right about the server not setting a cookie....I see where that fails now. Can't come up with anything now....should I just leave it on the client side? I'd much rather go through both client and server validation before moving to checkout.

Is this confusing? Sorry :( Anyway, thanks again.

DrS


0

Response Number 5
Name: anonproxy
Date: March 23, 2004 at 18:39:44 Pacific
Reply:

I don't believe you need to (re)write a window's URL to pass variables in $_GET. Just complete an HTTP transaction in the script.

"Can this be done in the header?"

That's all the browser is doing. Look for a class with some code to use.


0

Related Posts

See More



Response Number 6
Name: SN
Date: March 23, 2004 at 20:25:59 Pacific
Reply:

Here is a possible frameset solution (in case boa's setup doesn't work with mine or anonproxy's GET method.)

This is O.K., it's at least more transparent than the JS solution, and doesn't rely on the user having JS enabled.


foreach (product in products)
  $rowsdef=$rowsdef."0,";

$rowsdef=$rowsdef."*";

print "<FRAMESET rows='$rowsdef'>";

foreach (product in products)
  print "<FRAME src='product.url'>";

print "<FRAME src='confirmpage.php'></FRAMESET>";

I can't think of anything else, but if something dawns on me, I'll post back.

Good luck,
-SN


0

Sponsored Link
Ads by Google
Reply to Message Icon

Problem with CGI script- ... Link to Frames page



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: Open URLs in PHP w/out opening wind

Date in php www.computing.net/answers/webdevel/date-in-php-/506.html

post HTML page in PHP www.computing.net/answers/webdevel/post-html-page-in-php/1756.html

Stuck with ereg_replace in PHP www.computing.net/answers/webdevel/stuck-with-eregreplace-in-php/3003.html