473,900 Members | 3,343 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CURL and PHP Redirect

Hi All,

I have a small curl function which spits out a bunch of headers.

The CURL Code is:

$url="http://blahblah.com?Lo gon";
$ch = curl_init();
curl_setopt($ch , CURLOPT_URL, $url);
curl_setopt($ch , CURLOPT_FOLLOWL OCATION, 1);
curl_setopt($ch , CURLOPT_RETURNT RANSFER, 1);
curl_setopt($ch , CURLOPT_USERAGE NT, $_SERVER["HTTP_USER_AGEN T"]);
curl_setopt($ch , CURLOPT_REFERER ,
"http://blahblah.com/default.asp?v=" );
curl_setopt($ch , CURLOPT_VERBOSE , 0);
curl_setopt($ch , CURLOPT_HEADER, 1);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIE LDS,
"FormId=0&Confi g=0&RedirectURL =$RedirectURL&I dentification=$ UserID&Verifica tion=$Password& DB=$DB&Remember Logon=1&UseEnha ncedContent=1") ;
curl_setopt ($ch, CURLOPT_COOKIEJ AR, 'Ocookie.txt');
$content = curl_exec ($ch); # This returns HTML
curl_close ($ch);
print $content;
The HTML sspit out by the above code is:

HTTP/1.1 100 Continue Server: Microsoft-IIS/5.1 Date: Fri, 17 Mar 2006
00:14:25 GMT X-Powered-By: ASP.NET HTTP/1.1 200 OK Server:
Microsoft-IIS/5.1 Date: Fri, 17 Mar 2006 00:14:25 GMT X-Powered-By:
ASP.NET Connection: close Content-Type: text/html Refresh: 0;
URL=http://blahblah.com/default.asp?v= Set-Cookie: osaa=guest;
expires=Monday, 16-Mar-2009 00:14:25 GMT; path=/ Set-Cookie:
osab=guest; expires=Monday, 16-Mar-2009 00:14:25 GMT; path=/

All this is printed along with the existing HTML on which the above
curl code is written. How do I redirect the existing page to the one
setup in the headers by making sure of passing the whole header
information which is spit out by the curl code?

Thanks

Mar 17 '06
12 26525
ni*******@gmail .com wrote:
Hi,

The result of print_r(curl_ge tinfo($ch)); is as follows:

Array ( [url] => http://localhost/abc/default.asp?xyz = [http_code] => 0
[header_size] => 0 [request_size] => 0 [filetime] => 0
[ssl_verify_resu lt] => 0 [redirect_count] => 0 [total_time] => 0
[namelookup_time] => 0 [connect_time] => 0 [pretransfer_tim e] => 0
[size_upload] => 0 [size_download] => 0 [speed_download] => 0
[speed_upload] => 0 [download_conten t_length] => 0
[upload_content_ length] => 0 [starttransfer_t ime] => 0 [redirect_time]
=> 0 )


Obviously, you're using print_r(curl_ge tinfo($ch)); before
curl_exec(). Use it immediately after curl_exec()

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.bl ogspot.com/

Mar 25 '06 #11
Sorry, My Bad..

Here's the complete output:

The Local System Performace signifies that my curl code is pulling
stuff out a website running on local system.

The Remote System Performace signifies that my curl code is pulling
stuff out a website running on a remote system.

The remote system performance is faster.. eventhough i tweaked a lot of
curl, i am still unable to figure out why it is so slow on the local
machine.. :(

Local SYSTEM Performance
=============== =====

Array ( [url] => http://abc.com/share/xyz.dll?Logon [content_type] =>
text/html [http_code] => 200 [header_size] => 952 [request_size] => 305
[filetime] => -1 [ssl_verify_resu lt] => 0 [redirect_count] => 0
[total_time] => 0.052765 [namelookup_time] => 0.000145 [connect_time]
=> 0.000797 [pretransfer_tim e] => 0.000897 [size_upload] => 0
[size_download] => 84 [speed_download] => 1591 [speed_upload] => 0
[download_conten t_length] => 0 [upload_content_ length] => 0
[starttransfer_t ime] => 0.052367 [redirect_time] => 0 )

Array ( [url] => http://abc.com/share/default.asp?v= [content_type] =>
text/html [http_code] => 200 [header_size] => 357 [request_size] => 425
[filetime] => -1 [ssl_verify_resu lt] => 0 [redirect_count] => 0
[total_time] => 2.757411 [namelookup_time] => 4E-05 [connect_time] =>
0.000555 [pretransfer_tim e] => 0.000664 [size_upload] => 0
[size_download] => 29654 [speed_download] => 10754 [speed_upload] => 0
[download_conten t_length] => 29654 [upload_content_ length] => 0
[starttransfer_t ime] => 2.754259 [redirect_time] => 0 )
Remote System PERFORMANCE (This is very fast for some reason)
=============== =============== =============== =============== =
Array ( [url] => http://xyz.com/share/xyz.dll?Logon [content_type] =>
text/html [http_code] => 200 [header_size] => 863 [request_size] => 307
[filetime] => -1 [ssl_verify_resu lt] => 0 [redirect_count] => 0
[total_time] => 0.116149 [namelookup_time] => 5.8E-05 [connect_time] =>
0.034908 [pretransfer_tim e] => 0.034969 [size_upload] => 0
[size_download] => 213 [speed_download] => 1833 [speed_upload] => 0
[download_conten t_length] => 0 [upload_content_ length] => 0
[starttransfer_t ime] => 0.115845 [redirect_time] => 0 )

Array ( [url] => http://xyz.com/share/default.asp?v= [content_type] =>
text/html [http_code] => 200 [header_size] => 311 [request_size] => 445
[filetime] => -1 [ssl_verify_resu lt] => 0 [redirect_count] => 0
[total_time] => 0.870313 [namelookup_time] => 4.8E-05 [connect_time] =>
0.034595 [pretransfer_tim e] => 0.034689 [size_upload] => 0
[size_download] => 30134 [speed_download] => 34624 [speed_upload] => 0
[download_conten t_length] => 30134 [upload_content_ length] => 0
[starttransfer_t ime] => 0.756889 [redirect_time] => 0 )

Mar 27 '06 #12
ni*******@gmail .com wrote:
Sorry, My Bad..

Here's the complete output:

The Local System Performace signifies that my curl code is pulling
stuff out a website running on local system.

The Remote System Performace signifies that my curl code is pulling
stuff out a website running on a remote system.

The remote system performance is faster.. eventhough i tweaked a lot of
curl, i am still unable to figure out why it is so slow on the local
machine.. :(

<snip>

IIRC, libcurl on Windows machine will be little slower as compared
to Linux; not sure though.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Mar 28 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3362
by: D Benfer | last post by:
Hi all, Im a bit thrown by curl. I want to submit some order data on an ecommerce site via a form to a php page, where the data is saved to a database. Then I want to use curl to submit the form data I just saved (and redirect the user) to my secure credit card gateway. Problem is, they have their own secure payment screen where the credit card information is entered. I can't just retrieve the variable with a transaction...
9
8776
by: Dave Martin | last post by:
I've successfully used CURL to maneuver around and through sites but a new site I've been trying to work with has got me stumped. To retrieve the data I'm trying to get a login is required. If you go to any page in the "member" area without logging in you get directed to a https connection and hit login.php (ie: you end up at https://www.domain.com/login.php). The problem, I believe, lies in the fact that the form on that page...
5
19423
by: Dave | last post by:
Hi All, Can anyone suggest a reliable solution to php redirect?: header("Location: $redir_url"); if the above times out in $timeout seconds header("Location: $alt_redir_url"); Many thanks,
0
5827
by: susb8383 | last post by:
Hi, Is there a way to use cURL to redirect, but have the URL change to the new page? I have the following, but the URL remains as that of the original page after the redirect: <?php $url = "http://www.mydomain.com/test3.php"; $ch = curl_init(); // initialize curl handle
0
1523
by: existatus | last post by:
In a form there are entries like this: <input type="text" name="first_name" size="24" /> <input type="text" name="last_name" size="24" /> <input type="hidden" name="must_have" value="12345" /> <input type="hidden" name="recipient" value="myemail@comcast.net" /> <input type="hidden" name="redirect" value="http://mywebsite.com" /> <input type="hidden" name="subject" value="Topic In Question" />
56
7270
by: UKuser | last post by:
Hi, I'm not sure if this can be done as I've searched the web and this forum. I am using an online merchant provider and I must post certain variables to their webforms through a form on my website. The issue is that I need to gauge whether a user has any items in their basket to decide which page I redirect them too. I could
5
2987
by: ania.malicka85 | last post by:
Hello, I am playing with automatic redirection with PHP. As with GET is fairly simple (<meta http-equiv="refresh" content="3;url="http:// www.google.com/search?q=php"> how can I do similar thing with POST (lets assume that I want to add q = php to post variables). How can I do this? regards, Ann
3
15685
by: Sarah | last post by:
I was wondering if someone might be able to help me with this issue. I have a feeling this has something to do with my host's server settings as I used to be able to get CURL to follow redirects by setting CURLOPT_FOLLOWLOCATION set to true. I had a problem with my host's updating something in the past that gave me the error "CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set". My host worked on the...
3
6306
by: buzz2050 | last post by:
Hi all, I am using cURL for the first time. I need to login to a site and my cURL code to do the same is as follows: //curlScript.php <?php function getContent($url, $referer, $cookie_file_name, $post_fields='') {
0
9997
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10866
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10497
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8043
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5891
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6082
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4721
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4301
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.