indiWiz.com
SiteSearch:
Jump:

Site Map | WizTools.org | jCraze Blog
Web Developer's Den!
Home : WDD : ServerSide
This Article...
Print Version
Add Comment
View Comments
ServerSide
Apache on Linux
Apache User Directory Configuration
PostgreSQL Configuration
CGI: What and How?
PHP Jump Start Guide
Arrays in PHP
PHP and HTML Forms
Variable Passing in PHP
PHP 'include'
Drop-down Menu Navigation in PHP
Edit Your Site Online Using PHP
PHP MySQL Polling System
Dynamic, Search Engine Friendly Pages
Quot Ticker Using SSI
Regular Expressions Reference
PHP File Browser
PHP DB Deletion/Approval Script
Sections

Commniquè
Sign Guestbook!
Read Guestbook!
MailMe!

Drop-down Menu Navigation in PHP

You would have come across many large sites using this type of navigation, pointing to their various sections. In this tutorial I will teach you to create a navigation of this type pointing to the following sites:

  • indiWiz.com
  • indiatimes.com

My example will use two files, one is "navigation.html" and the other "jump.php".

File I: navigation.html

This file contains the drop-down menu. The code for the menu:

<form action="jump.php" type="get">
<select name="jumpMenu">
<option>indiWiz.com</option>
<option>indiatimes.com</option>
</select>
<input type="submit" value="Go!">
</form>

Note: The action attribute of the <form> tag points to "jump.php". Also the name of the select field is "jumpMenu".

File II: jump.php

This file, redirects the user to his selected site. This job is done by the following code:

<?
if($_GET['jumpMenu']=="indiWiz.com")
header("Location: http://www.indiwiz.com/");
elseif($_GET['jumpMenu']=="indiatimes.com")
header("Location: http://www.indiatimes.com/");
?>

Note:

  1. The above code is the FULL code of the file. "jump.php" need not contain any other code.
  2. The "header()" function sets the HTTP header of the document being sent. The "header()" function must be called before printing any characters.

Demo of this example.


User Comments

Add Comment

[Quick Stats: Number of main threads: 3, Number of sub-threads: 0]


Sign Guestbook | Who is Subhash?
The contents of this site are copyright© 2000-2008, indiWiz.com. All Rights Reserved.