473,395 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

cURL Redirect with Changing URL

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:

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. $url = "http://www.mydomain.com/test3.php"; 
  3. $ch = curl_init();    // initialize curl handle 
  4. curl_setopt($ch, CURLOPT_URL,$url); // set url to post to 
  5. curl_setopt($ch, CURLOPT_FAILONERROR, 1); 
  6. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects 
  7. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable 
  8. curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s 
  9. curl_setopt($ch, CURLOPT_POST, 1); // set POST method 
  10. curl_setopt($ch, CURLOPT_POSTFIELDS, "test=hello&test2=there"); // add POST fields 
  11. $result = curl_exec($ch); // run the whole process 
  12. curl_close($ch);  
  13. echo $result; 
  14. ?> 
  15.  
Thanks.
Mar 10 '07 #1
0 5593

Sign in to post your reply or Sign up for a free account.

Similar topics

1
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...
9
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...
9
by: Conrad F | last post by:
Hi, If any Microsoft people are listening.... Are there any plans for the new web language called "Curl" to be supported in .NET (ASP.NET)? I ask as Curl represents the first step to true OO...
12
by: niftyhawk | last post by:
Hi All, I have a small curl function which spits out a bunch of headers. The CURL Code is: $url="http://blahblah.com?Logon"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url);...
5
by: turnitup | last post by:
I have a security mechanism that checks that session variables are set, and if not, redirects. It seems, however, that CURL just ignores this statement and completely breaches my security. Does...
0
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" />...
3
by: Mikhail Kovalev | last post by:
I'm sending a html form with cURL to some file.php which does something with the sent data and at the end redirects me to some other URL, which is different every time, something like this: $ch...
3
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...
3
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.