?
Solved

PHP forward without using header

Posted on 2005-02-24
7
Medium Priority
?
1,241 Views
Last Modified: 2008-02-01
Is there a way to pass control from one php doc to another? I'm trying to achieve a similar programming style in php that I'm familiar with in java. I want to take the result of such and such then push them to a different page without using the header function. In java you can forward the response object to another class such as a jsp or a servlet.

Thanks
0
Comment
Question by:wgordy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 32

Expert Comment

by:Batalf
ID: 13396069
No, you have to use javascript or HTML to do that

Javascript

<script type="text/javascript">
location.href='newPage.html';
</script>
<?php
exit;
?>

or HTML

<META HTTP-EQUIV="Refresh"
      CONTENT="0; URL=newPage.html">
0
 

Author Comment

by:wgordy
ID: 13396239
Thanks, I was hoping there was a way to pass on the server side and not envolve the client. Oh well.
0
 
LVL 32

Expert Comment

by:Batalf
ID: 13396277
Why can't you use the header() function?

What you could do is to buffer the content at the start of your file

ob_start();

and then flush it below the part where you send people to another site with the header("location:.... ) statement

ob_end_flush();
0
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
LVL 20

Accepted Solution

by:
virmaior earned 2000 total points
ID: 13396314
there's another option

include 'mysecondfile.php'; exit(0);
0
 
LVL 32

Expert Comment

by:Batalf
ID: 13396469
To use include for a redirect sounds dangerous.

Batalf
0
 

Author Comment

by:wgordy
ID: 13396479
it's not a redirect with the client. It's a process control transfer. It's MVC architecture.
0
 
LVL 32

Expert Comment

by:Batalf
ID: 13396500
Sorry, misread your question. Great that it's solve though.

Batalf
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question