473,698 Members | 1,947 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 1622
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
1739
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
2018
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
2330
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
3815
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
1854
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
1129
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
12069
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
1458
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
3228
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
8671
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
8598
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,...
1
8887
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
8856
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...
0
7709
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6515
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
5858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2321
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1997
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.