ok, i have a webpage with an iframe, im creating a link script, so i can track my links. to do this im using URL variables, ie: page.php?p=7&l=1
where p goes into an array, $page[$p] that variable prints the page to be loaded in the iframe src and loaded in the middle. the l variable is the link variable, used again in an array for the link redirection.
im using a php session, the first thing i do on my host page is start a session, name it and then register my variable (l) so it can be used inside the iframe on another page.
i have one problem, it takes 2 clicks on the link for the l to be assigned the value for the link. without the session_register(l); the value is assigned first time, but only the host page has the value making the link script useless! ive also had a problem with changing a registered variable, i cant change the value without unsetting it, or unregistering it. can anyone help?
<?php
###################
## Start Session ##
###################
session_start(); ## starts session ##
session_unset(l); ## resets $l ##
session_unregister(l); ## resets $l ##
echo $l; ## Checks variable is assigned in the host page ##
######################
## End Session Data ##
######################
?>
<head>
<title>Dafsplace.co.uk - Sneak Preview!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="dafsplace.co.uk.css" rel="stylesheet" type="text/css">
</head>
<?php
include("bin/config.inc.php"); ## included the config file (not used as of yet) ##
include("bin/vars.inc.php"); ## contains the arrays for the pages and links ##
session_register(l); ## registers $l, hopefully with the URL variable value ##
?>
<body bgcolor="#536D84" topmargin="20">
<div align="center">
<table width="732" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="98" colspan="2" valign="top"><img src="images/header2.jpg" width="732" height="98"></td>
</tr>
<tr>
<td width="133" height="418" valign="top" class="navigation"><p>: <a href="index2.php?p=0">H
o m e</a> :</p>
<p>: <a href="index2.php?p=1">A b o u t</a> :</p>
<p>: <a href="index2.php?p=2">P o r t f o l i o</a> :</p>
<p>: <a href="index2.php?p=3">A r t i c l e s</a> :</p>
<p>: <a href="index2.php?p=4">G u e s t b o o k</a> :</p>
<p>: <a href="index2.php?p=5">C o n t a c t</a> :</p>
<p>: <a href="index2.php?p=6">M e m b e r s</a> :</p>
<p>: <a href="index2.php?p=7">L i n k s</a> :</p>
<p>: <a href="index2.php?p=8">P i c t u r e s</a> :</p>
<p>: <a href="index2.php?p=9">D o w n l o a d s</a> :</p>
<p>: <a href="index2.php?p=7&l=1">e r y c . c o . u
k</a> :</p>
<p>© Dafsplace.co.uk 2003</p>
</td>
<td width="599" valign="top" class="mainborder"><iframe src="page/
<?php
echo $page[$p]; ## prints page to be loaded in the iframe ##
?>
.php" align="left" frameborder="0" class="main" height="418" width="599" id="main" name="main"></iframe></td>
</tr>
</table>
</div>
</body>
</html>
Thats the host page (index2.php)
<?php
session_start(); ## starts the session with the $l value in (hopefully) ##
include("../bin/vars.inc.php"); ## includes the file holding the links array ##
if ($l != "") { ## asks if theres a link value present ##
#header("Location: $links[$1]");# just a test measure to see if its working ##
echo $links[$l]; ## just another test measure to see if its working ##
session_unregister(l); ## resets $l (hopefully) ##
}
session_unregister(l); ## resets $l (hopefully) ##
?>
thats my link script, not finished yet but it needs to work before its developed!
thanks in advance
Daf.