Jump to content

Redirecting to a URL in PHP


gwledig

Recommended Posts

Hi

I have a basic script running which will be called from a hyperlink on a Web page, this fires up the PHP script in the browser window and performs the stuff I want it to do (saves a file from the web to a local location), when the script has run I'm left with a blank screen.

 

I'd like to then redirect the page to a Website, but I've tried using the header declaration and this does redirect BUT the script doesnt run !

Does anyone know of a way to send the client/user to a URL after a function or procedure has run?

 

thanks

 

gwledig

Link to comment
https://forums.phpfreaks.com/topic/155035-redirecting-to-a-url-in-php/
Share on other sites

Hi, its basicly saving a web-published xml page as a local xml file (sharepoint uses horrible long urls without a proper .xml extension), so saving the sharepoint RSS file as .xml allows me to work with it online.

 

This script is just a php file which needs to run when the user has added news to a news feed in sharepoint, so I;ll provide them with a 'Publish' button which runs the php script to create the new RSS xml file. 

Unfortuantely when the user runs the php script it opens the php page and ends up just sitting there after its done its stuff building the xml file.

I suppose I could add a link 'Return to Intranet' or something but thats kinda messy...

Ideally I want the script to run then direct back to a url of my choosing...

thanks again folks...

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

<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'http://vocal-external.liv.ac.uk/sites/catherallp-test/news/_layouts/listfeed.aspx?List={C1F668FA-F047-427F-93B0-8344EA008518}');

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$remoteFileContents = curl_exec($ch);

 

$localFilePath = "C:\Mowes\www";

$localFileName = "ok.xml";

$newFileHandle = fopen($localFilePath."/".$localFileName, "w");

fwrite($newFileHandle, $remoteFileContents);

fclose($newFileHandle);

 

echo '<h1 style="font-face: arial; color: #0033CC;"><strong>Publishing News Page, Please Wait....</strong></h1>';

 

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.