Help - Search - Members - Calendar
Full Version: redirecting to input url?
HTMLHelp Forums > Web Authoring > Web Site Functionality
olev_ait
hello
what i want to do is have a form on my web page with text input so that if a user enters an url (http://address or just address) the page redirects to that url. i have tryed to search but i'm not quite sure what i should search for. if it's not possible with simple html i would prefer solutions for php and/or javascript.

thanks

ps. sorry for my bad enlish
Darin McGrew
Why? Most browsers provide a built-in mechanism for users to enter a URL and go to that URL. Users will already be familiar with that mechanism.
olev_ait
yes, but this leaves a lot more noticeable traces behind
i know lots of peaople who use this built-in mechanism as bookmarks (or favorites) and they dont want any crap addresses in there (a little silly but what can i do, they say that its a lot more handy for them)
and besides.. i have spent too much time searching for that solution to just give it up now
stjepan
You can use form for sending mail, delete what you don't need and use variable 'redirect'. You can find script here http://www.scriptarchive.com/readme/formmail.html
Christian J
QUOTE(stjepan @ Nov 8 2006, 02:00 PM) *

You can use form for sending mail, delete what you don't need and use variable 'redirect'. You can find script here http://www.scriptarchive.com/readme/formmail.html


I wouldn't base anything on Matt's FormMail, it's lack of security has allowed it to be abused as a spam engine.

With the PHP header() function you might redirect users depending on the form data they submit. Note that this causes a privacy issue, since you can see which sites the user enter.
stjepan
QUOTE
Matt's FormMail, it's lack of security has allowed it to be abused as a spam engine.

I didn't know that... sad.gif
Peter1968
It's improved over the years, but FormMail still isn't up to scratch security-wise. Shame it's still so popular.
Christian J
There are drop-in replacements for Matt's scripts at http://nms-cgi.sourceforge.net/about.html AFAIK these are more secure.
olev_ait
thanks for all who answered... going to try the nms solution when i have some free time
pandy
QUOTE(Christian J @ Nov 8 2006, 03:25 PM) *

I wouldn't base anything on Matt's FormMail, it's lack of security has allowed it to be abused as a spam engine.

This is four years old, but still thought-worthy. Right after Nimda.
http://web.archive.org/web/20031203161108/...s_q1_2002.shtml
olev_ait
<html>
<HEAD>
<script LANGUAGE="JavaScript">
function whatURL() {
window.location= 'http://' + document.form1.url.value;
}
</SCRIPT>
</HEAD>
<BODY>
<FORM name=form1>
<input type=text name="url">
<input type=button onClick="whatURL()" value="Go">
</FORM>
...

it works fine when i press the go button, but what should i do to make it work with pressing ENTER too?
tried several things but none working so far.. so i'm hopeing to get some explicit code from you, not just recommendations what to try.
thanks
stjepan
QUOTE
it works fine when i press the go button, but what should i do to make it work with pressing ENTER too?
tried several things but none working so far.. so i'm hopeing to get some explicit code from you, not just recommendations what to try.thanks

Example in details at http://www.cs.tut.fi/~jkorpela/forms/enter.html
Look for "Make ENTER submit"
Christian J
QUOTE(olev_ait @ Nov 4 2006, 12:44 PM) *

yes, but this leaves a lot more noticeable traces behind
i know lots of peaople who use this built-in mechanism as bookmarks (or favorites) and they dont want any crap addresses in there (a little silly but what can i do, they say that its a lot more handy for them)


Using a form will not prevent the destination URL from being saved in the browser history.

Anyway you might experiment with the script below. It should work wether the user writes out "http://" or not, but does not work with other protocols like "ftp://". It does add a "?" after the destination URL but that shouldn't matter (and will not circumvent the auto-complete feature of the browser):

CODE
<form action="#" onsubmit="this.action='http://'+document.getElementById('url').value.replace('http://', '');">
<input type="text" id="url">
<input type="submit" value="go">
</form>
<noscript>Javascript is required to use the above form.</noscript>
olev_ait
thanks Christian... and everybody else...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.