/    Sign up×
Community /Pin to ProfileBookmark

Working with two JumpMenu

I tried using the redirect.php to direct the behavior of the viewpassQ.php JumpMenu but the behavior is still not okay as it work just on one subject rather than all the subjects. I have designed webpages for each subjects on yearly basis ranging from 2000-2011 and intend to add 2012 and subsequent years later. I wish that as soon as a visitor selects a subject and a year, the visitor should be directed to the corresponding webpage(eg. Biology-2011 = Biologypassq2011.php).

viewpassQ.php
<tr>
<td><select name=”jumpMenu” id=”jumpMenu”>
<option selected=”selected”>Select Subject</option>
<option value=”Biology”>Biology</option>
<option>Chemistry</option>
<option>Christian Religious Knowledge</option>
<option>Commerce</option>
<option>Economics</option>
<option>English Language</option>
<option>Government</option>
<option>Mathematics</option>
<option>Physics</option>
<option>Principle of Accounts</option>
<option>Agricultural Science</option>
</select>
<div align=”center”>
<label></label>
</div></td>
<td>&nbsp;</td>
<td><select name=”jumpMenu2″ id=”jumpMenu2″>
<option selected=”selected”>Select Year</option>
<option value=”2000″>2000</option>
<option value=”2001″>2001</option>
<option value=”2002″>2002</option>
<option value=”2003″>2003</option>
<option value=”2004″>2004</option>
<option value=”2005″>2005</option>
<option value=”2006″>2006</option>
<option value=”2007″>2007</option>
<option value=”2008″>2008</option>
<option value=”2009″>2009</option>
<option value=”20010″>2010</option>
<option value=”20011″>2011</option>
<option value=”20012″>2012</option>
</select></td>
</tr>

redirect.php
<?php
$jumpMenu=$_POST[‘jumpMenu’];
$jumpMenu2=$_
POST[‘jumpMenu2’];

if($jumpMenu==’Biology’ && $jumpMenu2==’2000′){
header(“Location: passq/biologypassq2000.php”);
}

?>

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 04.2012 — [code=php]
<?php
$categories = array(
'Biology' => 'biology',
'Chemistry' => 'chemistry',
'Christian Religious Knowledge' => 'crk', // whatever actual file name is?
'Commerce' => 'commerce' // etc....
);

if(!empty($_POST['jumpMenu']) and isset($categories[$_POST['jumpMenu']])) {
if(!empty($_POST['jumpMenu2']) and ctype_digit($_POST['jumpMenu2'])) {
$file = $categories[$_POST['jumpMenu']].'passq'.$_POST['jumpMenu2'].'.php';
if(file_exists($_SERVER['DOCUMENT_ROOT']).'passq/'.$file) {
header('Location: passq/'.$file);
exit;
}
}
}
else {
// handle errors here?
}
[/code]
Copy linkTweet thisAlerts:
@princegiftedauthorNov 06.2012 — [code=php]
<?php
$categories = array(
'Biology' => 'biology',
'Chemistry' => 'chemistry',
'Christian Religious Knowledge' => 'crk', // whatever actual file name is?
'Commerce' => 'commerce' // etc....
);

if(!empty($_POST['jumpMenu']) and isset($categories[$_POST['jumpMenu']])) {
if(!empty($_POST['jumpMenu2']) and ctype_digit($_POST['jumpMenu2'])) {
$file = $categories[$_POST['jumpMenu']].'passq'.$_POST['jumpMenu2'].'.php';
if(file_exists($_SERVER['DOCUMENT_ROOT']).'passq/'.$file) {
header('Location: passq/'.$file);
exit;
}
}
}
else {
// handle errors here?
}
[/code]
[/QUOTE]


Thanks so much for your response. see below for some change made to the php and the HTML. But i still haven't achieved my goal.

<?php

$categories = array(

'Biology' => 'biology',

'Chemistry' => 'chemistry',

'Christian Religious Knowledge' => 'christian religious knowledge',

'Commerce' => 'commerce'

'Economics' => 'economics'

'English Language' => 'english language'

'Government' => 'government'

'Mathematics' => 'mathematics'

'Physics' => 'physics'

'Principle of Accounts' => 'principle of accounts'

'Agricultural Science' => 'Agricultural Science'

);

if(!empty($_POST['jumpMenu']) and isset($categories[$_POST['jumpMenu']])) {

if(!empty($_POST['jumpMenu2']) and ctype_digit($_POST['jumpMenu2'])) {

$file = $categories[$_POST['jumpMenu']].'passq'.$_POST['jumpMenu2'].'.php';

if(file_exists($_SERVER['DOCUMENT_ROOT']).'passq/'.$file) {

header('Location: passq/'.$file);

exit;

}

}

}

else {

// handle errors here?

}

HTML

<body>

<form id="form1" name="form1" method="post" action="redirect.php">

<div align="center">

<p><img src="Untitled-7.png" width="862" height="194" /> </p>

<table width="866" height="81" border="0" cellpadding="5" bgcolor="#CC3300">

<tr>

<th colspan="3" bgcolor="#F0F0F0" scope="col"><ul id="MenuBar1" class="MenuBarHorizontal">

<li><a href="index.php">Home</a> </li>

<li><a href="thepassutme.php">The Pass</a></li>

<li><a href="#">Universities</a> </li>

<li><a href="#">Books</a></li>

<li><a href="Contact.php">Contact</a></li>

</ul> </th>

</tr>

<tr>

<th colspan="3" scope="row"><label></label></label>

<div align="center"></div>

<label></label></th>

</tr>

<tr>
<td colspan="3" scope="row"><div align="center">
<table width="398" height="235" border="3" cellspacing="3" bordercolor="#990000" bgcolor="#00FF00">
<tr>
<td><div align="center">
<table width="200" border="0">

<tr>
<td><select name="jumpMenu" id="jumpMenu">
<option selected="selected">Select Subject</option>
<option value="Biology">Biology</option>
<option value="Chemistry">Chemistry</option>
<option value="Christian Religious Knowledge">Christian Religious Knowledge</option>
<option value="Commerce">Commerce</option>
<option value="Economics">Economics</option>
<option value="English Language">English Language</option>
<option value="Government">Government</option>
<option value="Mathematics">Mathematics</option>
<option value="Physics">Physics</option>
<option value="Principle of Accounts">Principle of Accounts</option>
<option value="Agricultural Science">Agricultural Science</option>
</select>
<div align="center">
<label></label>
</div></td>
<td>&nbsp;</td>
<td><select name="jumpMenu2" id="jumpMenu2">
<option selected="selected">Select Year</option>
<option value="2000">2000</option>
<option value="2001">2001</option>
<option value="2002">2002</option>
<option value="2003">2003</option>
<option value="2004">2004</option>
<option value="2005">2005</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="20010">2010</option>
<option value="20011">2011</option>
<option value="20012">2012</option>
</select></td>
</tr>
<tr>
<td colspan="3"><div align="center">
<label></label>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div></td>
</tr>
<tr>
<td colspan="3"><div align="center">
<label></label>
<input type="submit" name="button" id="button" value="Search" />
</div></td>
</tr>


please i will be grateful if you can take more time to see me through this.
Copy linkTweet thisAlerts:
@princegiftedauthorNov 07.2012 — Parse error: syntax error, unexpected ''Economics'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in C:xampphtdocsthepassredirect.php on line 7

Above is the error information received when i tried the above.
×

Success!

Help @princegifted spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...