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> </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");
}
?>
PHP Code:
<?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? }
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in
Nation
eBookworm.us
Originally Posted by
NogDog
PHP Code:
<?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?
}
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> </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> </p>
<p> </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.
Parse error: syntax error, unexpected ''Economics'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in C:\xampp\htdocs\thepass\redirect.php on line 7
Above is the error information received when i tried the above.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks