473,406 Members | 2,710 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,406 software developers and data experts.

Redirecting a page during an xmlRequest script

I have a page that sends a request to another PHP page on my site.
If I try and set the header in the page that is being called, with
header(Location: ...), the site doesn't get redirected like I'd like it
to, it just writes a response to the original page. The response that
it writes is the HTML of the page that I'd like the site to be
redirected to.
Is there a way that I can redirect from the script that is being called
through an xmlRequest?
Thanks a lot for any help.

May 28 '06 #1
5 1610
Rik
mh******@gmail.com wrote:
I have a page that sends a request to another PHP page on my site.
If I try and set the header in the page that is being called, with
header(Location: ...), the site doesn't get redirected like I'd like
it to, it just writes a response to the original page. The response
that it writes is the HTML of the page that I'd like the site to be
redirected to.
Is there a way that I can redirect from the script that is being
called through an xmlRequest?


This is logical, and has more to do with javascript then PHP:
1. You make a request using js.
2. Requested page is a PHP-script.
3. PHP-script answers that requests should be redirected to other page.
4. javascript requests the page where it is redirected to, as it should, and
prints it on the current page.

If there is a possibility you get content, and not just redirects, from the
PHP page, ask in a javascript group how to achieve this.

If the request is dependant on other javascript actions, ask in a javascript
group how to achieve this.

If the script in questions only redirects, and the request isn't dependant
on other js actions/functions: don't use javascript, just link to the
script.

Grtz,
--
Rik Wasmus
May 28 '06 #2
Are you by any chance writing anything prior to the header()?

Even a blank line prior would invalidate the header() and the bnrowser
would just display it.

May 29 '06 #3
So then is this script illegal? If so, how do you redirect a page after
you check to see if the user is logged in?

<?php

if ($_SESSION['cmpid'] == '')
header('Location: http://campaigns.hooplah.ca/Host/noCampaign.htm');
else
$cmpid = $_SESSION['cmpid'];

?>

May 29 '06 #4
That scropt looks legal, but you have to make sure it comes before
ANYTHING being written or sent to the browser.

May 29 '06 #5
Herman wrote:
So then is this script illegal? If so, how do you redirect a page after
you check to see if the user is logged in?

<?php

if ($_SESSION['cmpid'] == '')


Use isset() for safe.

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

Jun 4 '06 #6

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

Similar topics

6
by: slash | last post by:
Hi, I am new to JavaScript and I have been sifting through the previous posts about some specific help I need with a redirect problem. No luck there! Could someone take a look and give me some...
11
by: Peter | last post by:
I have a modest website that uses a lot of Javascript. If anybody views the site and does not have Javascript enabled I want to politely redirect them to another page, so I put this bit of code...
3
by: lozd | last post by:
Would appreciate any solutions people could offer for this. Basically I wan't to use a frameset with an aspx page as the contents rather than a htm page and I'd like to be able to redirect the...
0
by: Leslie McGann | last post by:
Hi, I need to open a different pdf file in an iframe each time the user clicks a button. I also need to open the pdf to a specific page each time. The pdfs in question are located on a web...
1
by: Bilbo | last post by:
Hello, How do I programatically redirect a page in "another frame" using C# in ASP.NET? Server.Transfer redirects the current page...not a different frame. Thanks.
3
by: Shreyas | last post by:
I am a new user writing some scripts to store data entered via a browser into a database. I have several content pages, and one "processing" page. A content page often has a form like this: ...
5
by: twiggy182 | last post by:
Hi, I really need you help because I'm not very familliar with ASP and I could not find any solution to my problem. To put you in situation, I have a CGI to which I send a file name, and that...
1
by: sreekeerthi | last post by:
hi friends...this is keerthi...i am doing a project where i want to redirect my page when ever the back button is clicked...for this i am using window.onbeforeunload method..and for page redirection...
41
by: amygdala | last post by:
Hello all, I have posted a similar question in comp.lang.php in the past, but haven't had any response to it then. I kinda swept the problem under the rug since then. But I would really like to...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...

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.