tendral;10948979 wrote:Hi people,
When the user presses on the Browse By Subject link, the code in red in book_list.php is not getting executed. Does anyone know why?
index.php
<a name="sel_subject" href="book_list.php" >Browse By Subject</a>
book_list.php
[COLOR="Red"]if (isset ($_POST["sel_subject"]))
{echo "select subject";
create_select_subject($_POST["subject"]);
}[/COLOR]
thank you
Yeah, $_POST is for submitted forms that use the POST method. If you wanted to use a link, you might want to consider something more like this:
index.php
<a href="book_list.php?subj=sel_subject" >Browse By Subject</a>
and then use $_GET['subj'] to get what was passed through the URL, in this case, it would return the value of 'sel_subject'. This comes in handy if you have a few links to the same page but that page displays different content depending on which link they clicked on. If you wanted to add an additional variable in the URL, you could do that like this:
index.php
<a href="book_list.php?subj=sel_subject&othervariable=othervalue" >Browse By Subject</a>
and then you could use $GET['subj'] to return 'sel_subject' and $GET['othervariable'] to return 'othervalue'
Hopefully this helps