Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Auto Executing a URL from PHP code

Posted on 2003-11-14
6
Medium Priority
?
245 Views
Last Modified: 2007-12-19
Hi,

I need to automatically call a file from PHP.  I am currently using the HTML headder META AUTOLOAD code
-- but need to know how to set it off from PHP since I need PHP to do somthing for me first.

<?php
$ms_id=$_GET["p"];
....
....
if (!session_is_registered('mst')) {
      session_register('mst');
      $HTTP_SESSION_VARS['mst'] = $ms_id;
}
....setting some meore vars via SQL etc....
........
?>
<hr><a href="proj.buildup.log.activity.php">Edit Log</a>

This last bit needs to auto execute ... This is the manual way.

I seem to have seen a function to do this but cannot find it in my megre archives.
0
Comment
Question by:kokriba
[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
6 Comments
 
LVL 6

Expert Comment

by:DoppyNL
ID: 9746976
you can do a simple include:

include('proj.buildup.log.activity.php');

that will include that page on the current location.

if you don't want the content to be in the current page you can use output buffering and clear the buffer afterwards.
tou can also use fopen:

fopen('http://domain.com/file.php');

in this case you have to include the full url to the file (otherwise the php won't be processed)
and you have to retrieve the actual page with a read function (you don't have to do anything else with it though).

I would go with the include, as it seems that the file is on your own server so you can make sure that the file doesn't output a thing :)
0
 
LVL 1

Expert Comment

by:vincevincevince
ID: 9755522
You mean you want it to finish your code, then load a new page?

in that case you should use

header("http://newlocation.co.uk");

make sure you have not echoed or outputted ANY data to the browser before this is called.  use a fully qualified URL.
0
 
LVL 11

Expert Comment

by:Zontar
ID: 9755702
You can also use output buffering to get around the output/header issue somewhat and to process output before sending it to the browser. Look up ob_start() and ob_flush() (and related functions)  in the PHP Manual.
0
 

Author Comment

by:kokriba
ID: 9769833
Hi,
These did not seem to work but I did it this way

<html>
<head>
      <meta http-equiv="Content-Type" content="text/html">

<!- HERE IS THER NB BIT ->
      <meta http-equiv="Refresh" content="1; URL=http://wphilip/public/aplets/ic_proj_man/proj.buildup.log.activity.php">
      <title>Interrim Storage</title>
</head>
<body>
<?php
//      ther URL /filename.php?f=fileToDL&t=TypeOfFileToDL
$ms_id=$_GET["p"];
include('/incl/db.list.php');
include_once('/formal_includes/adodb/adodb.inc.php');
echo($ms_id);
$use_db = $dbs_projects;
if (!session_is_registered('mst')) {
      session_register('mst');
      $HTTP_SESSION_VARS['mst'] = $ms_id;
}
else{
      $HTTP_SESSION_VARS['mst'] = $ms_id;
}
$var_ms = $HTTP_SESSION_VARS['mst'];
include('/incl/db.connect.php');
      $sql = "SELECT proj_id
                        FROM t_proj_makup
                        WHERE t_proj_makup.id=".$HTTP_SESSION_VARS['mst'];
            $rs = $db->Execute($sql);
            $proj_find = $rs->fields[0];
      $db->close;
if (!session_is_registered('prj')) {
      session_register('prj');
      $HTTP_SESSION_VARS['prj'] = $proj_find;
}
else{
      $HTTP_SESSION_VARS['prj'] = $proj_find;
}      
$var_pj = $HTTP_SESSION_VARS['prj'];      
//include('proj.buildup.log.activity.php');
echo('<hr>'.$var_pj);
//header("Location: proj.buildup.log.activity.php");
//header("http://wphilip/public/index.htm");//aplets/ic_proj_man/proj.buildup.log.activity.php");
?>
<hr><a href="proj.buildup.log.activity.php" id="1">Edit Log if does not load automaticcally</a>
</body>
</html>
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12573092
PAQed with points refunded (125)

modulo
Community Support Moderator
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

722 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