We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
PHP Dropdown Navigation
Topic Started: Aug 20 2005, 08:16 PM (319 Views)
stahfiah
Member Avatar
A woman clearly in a heightened state of arousal.
[ *  *  *  *  * ]
Something I wrote up.
Preview: Here
Quote:
 
<?php
if($submit = "Go") {
$s = $_POST['s'];
header("Location: $s");
}
$links = array("Google" => "http://google.ca",
"Yahoo" => "http://yahoo.com",
"My Deviantart" => "http://ayf.deviantart.com",
"IFSZ" => "http://ifsz.net");
?>
<form name="form1" method="post" action="<?PHP $_SERVER['PHP_SELF']?>">
  <select name="s">
<?php
foreach($links as $key => $value)
echo "<option value='$value'>$key</option>"
?>
  </select>
  <input type="submit" name="Submit" value="Go">
</form>


The URLs are stored in $links, and to add more, just add it in the format of "Sitename" => "siteurl",
Offline Profile Quote Post Goto Top
 
Epsilekt
Member Avatar
Member
[ *  *  *  *  *  * ]
Cool. ^_^ I'm going to try to make one just like it using javascript so it can be used on InvisionFree forums.
Offline Profile Quote Post Goto Top
 
Ordinator
hay yoo guyz!!1
[ *  *  *  *  * ]
"Ripway Web Hosting
--------------------------------------------------------------------------------
Home Page Not Found "
Offline Profile Quote Post Goto Top
 
Websurfer
Member Avatar
Also known as Myr
[ *  *  *  *  *  *  * ]
Alex, not everyone uses global variables....

It IS a security risk to do those! Instead, add $s = $_POST['s'];, then you can do your header("Location: $s");.

So replace:
Code:
 
if($submit = "Go") {
header("Location: $s");
}
With:
Code:
 
if($submit = "Go") {
$s = $_POST['s'];
header("Location: $s");
}


Other than that, looks nice
Offline Profile Quote Post Goto Top
 
MrsSim
Member Avatar
Splendiferous™
[ *  *  *  *  *  * ]
Myr
Aug 20 2005, 10:41 PM
Alex, not everyone uses global variables....

It IS a security risk to do those! Instead, add $s = $_POST['s'];, then you can do your header("Location: $s");.

So replace:
Code:
 
if($submit = "Go") {
header("Location: $s");
}
With:
Code:
 
if($submit = "Go") {
$s = $_POST['s'];
header("Location: $s");
}


Other than that, looks nice

Follow Myr's advice... if you don't limit $s to the requested location, someone can alter it and go ANYWHERE they want... including private sections.

So follow Myr's advice and you'll be fine.
Offline Profile Quote Post Goto Top
 
stahfiah
Member Avatar
A woman clearly in a heightened state of arousal.
[ *  *  *  *  * ]
MrsSim
Aug 21 2005, 05:39 PM
Myr
Aug 20 2005, 10:41 PM
Alex, not everyone uses global variables....

It IS a security risk to do those!  Instead, add $s = $_POST['s'];, then you can do your header("Location: $s");.

So replace:
Code:
 
if($submit = "Go") {
header("Location: $s");
}
With:
Code:
 
if($submit = "Go") {
$s = $_POST['s'];
header("Location: $s");
}


Other than that, looks nice

Follow Myr's advice... if you don't limit $s to the requested location, someone can alter it and go ANYWHERE they want... including private sections.

So follow Myr's advice and you'll be fine.

I tried that but his code didn't work.

// Edit again.

gah wtf its not working now
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Technology Chat · Next Topic »
Add Reply