473,721 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1625
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('Locatio n: http://campaigns.hoopl ah.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
1743
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 suggestions. I could really use some help. What I am trying to accomplish is the following: -grab the user bookmarked URL. -strip some of the URL from the beginning -pass what's leftover of the URL and append that to a new URL.
11
2024
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 in my <head> section : <script type="text/javascript" language="JavaScript">document.write("<!"+"--")</script> <meta http-equiv="Refresh" content="0; URL=noscript.html"> <!--//-->
3
2334
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 main page from the code behind the contents page. I want to do this to allow the use of asp "linkbuttons" instead of hyperlinks so I can do a little processing before redirecting. The main reason for this to prevent hyperlinks of pages that have...
0
3816
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 site/virtual directory on a different server. I'm using the RegisterStartupScript function to perform a redirect to the new pdf the first time the page is loaded and each time this button is clicked. The problem is that the pdf document only...
1
1857
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
1130
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: <form method=POST action=processing.py> <input type=text name=username> .... And the processing page goes like this:
5
12071
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 script return me that file. But for security reason, I don't want to publish the address of this CGI, so I encapsulated it in an ASP file. This way, only this ASP file knows where the CGI is.
1
1462
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 i am using window.location and my code is as follows <html> <head> <script type="text/javascript"> var confirm = true; window.onbeforeunload = unload; function unload() { if(confirm)
41
3232
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 resolve this issue once and for all now. The problem might be PHP related but since I only develop applications using PHP, I'm not a hundred percent sure. Therefor I've taken the liberty to crosspost to comp.lang.php and alt.www.webmaster. I...
0
8730
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9215
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
9131
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,...
1
6669
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
4484
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
4753
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3189
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
2576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2130
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.