kokriba
asked on
Auto Executing a URL from PHP code
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('m st')) {
session_register('mst');
$HTTP_SESSION_VARS['mst'] = $ms_id;
}
....setting some meore vars via SQL etc....
........
?>
<hr><a href="proj.buildup.log.act ivity.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.
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('m
session_register('mst');
$HTTP_SESSION_VARS['mst'] = $ms_id;
}
....setting some meore vars via SQL etc....
........
?>
<hr><a href="proj.buildup.log.act
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.
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.
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.
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.
ASKER
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 =TypeOfFil eToDL
$ms_id=$_GET["p"];
include('/incl/db.list.php ');
include_once('/formal_incl udes/adodb /adodb.inc .php');
echo($ms_id);
$use_db = $dbs_projects;
if (!session_is_registered('m st')) {
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_SE SSION_VARS ['mst'];
$rs = $db->Execute($sql);
$proj_find = $rs->fields[0];
$db->close;
if (!session_is_registered('p rj')) {
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.lo g.activity .php');
echo('<hr>'.$var_pj);
//header("Location: proj.buildup.log.activity. php");
//header("http://wphilip/public/index.htm");//aplets/ic_p roj_man/pr oj.buildup .log.activ ity.php");
?>
<hr><a href="proj.buildup.log.act ivity.php" id="1">Edit Log if does not load automaticcally</a>
</body>
</html>
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
$ms_id=$_GET["p"];
include('/incl/db.list.php
include_once('/formal_incl
echo($ms_id);
$use_db = $dbs_projects;
if (!session_is_registered('m
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.
$sql = "SELECT proj_id
FROM t_proj_makup
WHERE t_proj_makup.id=".$HTTP_SE
$rs = $db->Execute($sql);
$proj_find = $rs->fields[0];
$db->close;
if (!session_is_registered('p
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.lo
echo('<hr>'.$var_pj);
//header("Location: proj.buildup.log.activity.
//header("http://wphilip/public/index.htm");//aplets/ic_p
?>
<hr><a href="proj.buildup.log.act
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
include('proj.buildup.log.
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 :)