I have a problem where I need to pass two variables using GET from a form I
have, to solve a page selection problem I have.
The code is written that if a new visitor arrives at the front page of the
site, because the page id is null, PHP loads the default design. But when
I execute one of my other pages which has a form on it, because I cannot
pass back the id of the page that the form is on (the "submit" GET's the
desired page id only), instead of calling the new page, it executes the
"null" part of the script again. Despite the GET having a different id
(track), it refuses to execute because the page == null code.
The variable of the page needed to be displayed is GET'ed (it's in the
browser URL, and an echo statement in the PHP confirms the value GET'ed,
and lack of the original page id.
How can I get the code to pass both the page id and the data of the
selected form item at the same time?
Dariusz
The PHP
<?
if ($_GET['page'] == NULL)
{
echo $_GET['track']; //value passed from the HTML form
echo $_GET['page']; //value of the page id
include ("index2.php ");
}
elseif ($_GET['page'] == index)
{
header ("Location: /index.php");
}
elseif ($_GET['page'] != index)
{
include ("html/".$_GET['page'].".shtml");
}
elseif ($_GET['track'] == a01-t01)
{
include ("html/lyrics/".$_GET['track'].".htm");
}
?>
The form HTML
<FORM method="GET" action="../../index.php" name="myform01" >
<select name="track">
<option value="a01-t01" SELECTED>Track 01</option>
<option value="a01-t02">Track 02</option>
<option value="a01-t03">Track 03</option>
<option value="a01-t04">Track 04</option>
</select>
<BR><BR>
<input type="submit" value="Go get the lyrics">
</FORM>
have, to solve a page selection problem I have.
The code is written that if a new visitor arrives at the front page of the
site, because the page id is null, PHP loads the default design. But when
I execute one of my other pages which has a form on it, because I cannot
pass back the id of the page that the form is on (the "submit" GET's the
desired page id only), instead of calling the new page, it executes the
"null" part of the script again. Despite the GET having a different id
(track), it refuses to execute because the page == null code.
The variable of the page needed to be displayed is GET'ed (it's in the
browser URL, and an echo statement in the PHP confirms the value GET'ed,
and lack of the original page id.
How can I get the code to pass both the page id and the data of the
selected form item at the same time?
Dariusz
The PHP
<?
if ($_GET['page'] == NULL)
{
echo $_GET['track']; //value passed from the HTML form
echo $_GET['page']; //value of the page id
include ("index2.php ");
}
elseif ($_GET['page'] == index)
{
header ("Location: /index.php");
}
elseif ($_GET['page'] != index)
{
include ("html/".$_GET['page'].".shtml");
}
elseif ($_GET['track'] == a01-t01)
{
include ("html/lyrics/".$_GET['track'].".htm");
}
?>
The form HTML
<FORM method="GET" action="../../index.php" name="myform01" >
<select name="track">
<option value="a01-t01" SELECTED>Track 01</option>
<option value="a01-t02">Track 02</option>
<option value="a01-t03">Track 03</option>
<option value="a01-t04">Track 04</option>
</select>
<BR><BR>
<input type="submit" value="Go get the lyrics">
</FORM>
Comment