473,327 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Form field entry directs to diff URLs based on entry?

I have been given an interesting task:

Make a page with a single form field, which is to take a name (first
and last), and regardless of case or whether there is a space between
the first and last name, when the user hits the submit button it takes
them to a URL that has been assigned to that name.

Example 1:

user enters "Tony Tiger" in the field and hits submit.

user is then sent to tonytiger.exampledomain.com.

Example 2:

user enters "johnnywalker" in the field and hits submit.

user is then sent to johnnywalker.exampledomain.com.

Thanks very much for any advice!

Apr 29 '06 #1
14 1716
In message <11**********************@y43g2000cwc.googlegroups .com>,
AtomicBob <ro**************@gmail.com> writes
I have been given an interesting task:

Make a page with a single form field, which is to take a name (first
and last), and regardless of case or whether there is a space between
the first and last name, when the user hits the submit button it takes
them to a URL that has been assigned to that name.


I've upload something to get your started to:
<http://www.spam-free.org.uk/pages/login.zip>.

It's a bit basic, and you might want to think about what should happen
if someone enters a name that doesn't exist.

Presumably this is for a referrals type application and security isn't
an issue.
--
Martin Jay
Phone/SMS: +44 7740 191877
Fax: +44 870 432 5180
Apr 29 '06 #2

"Martin Jay" <ma****@spam-free.org.uk> skrev i meddelandet
news:6X**************@spam-free.org.uk...
In message <11**********************@y43g2000cwc.googlegroups .com>,
AtomicBob <ro**************@gmail.com> writes
I have been given an interesting task:

Make a page with a single form field, which is to take a name (first
and last), and regardless of case or whether there is a space between
the first and last name, when the user hits the submit button it takes
them to a URL that has been assigned to that name.


I've upload something to get your started to:
<http://www.spam-free.org.uk/pages/login.zip>.

It's a bit basic, and you might want to think about what should happen
if someone enters a name that doesn't exist.

What do you think it would happen?
--
Luigi Donatello Asero
https://www.scaiecat-spa-gigi.com/sv/faktaomitalien.php
今天二零零*年四月二十九日
星期五*

Apr 29 '06 #3
In message <P5*******************@newsb.telia.net>, Luigi Donatello
Asero <ja**************@telia.com> writes
"Martin Jay" <ma****@spam-free.org.uk> skrev i meddelandet
news:6X**************@spam-free.org.uk...
In message <11**********************@y43g2000cwc.googlegroups .com>,
AtomicBob <ro**************@gmail.com> writes
>I have been given an interesting task:
>
>Make a page with a single form field, which is to take a name (first
>and last), and regardless of case or whether there is a space between
>the first and last name, when the user hits the submit button it takes
>them to a URL that has been assigned to that name.
I've upload something to get your started to:
<http://www.spam-free.org.uk/pages/login.zip>.

It's a bit basic, and you might want to think about what should happen
if someone enters a name that doesn't exist.
What do you think it would happen?


It depends how the server is configured: visitors may get a 'server not
found' error, a 404 error, a default page, or maybe something else.

The script could be modified to deal with unexpected names, either by
looking names up in a database or checking them against a list. Or they
could be hard-coded into it. :(
--
Martin Jay
Apr 29 '06 #4

"Martin Jay" <ma****@spam-free.org.uk> skrev i meddelandet
news:vj**************@spam-free.org.uk...
In message <P5*******************@newsb.telia.net>, Luigi Donatello
Asero <ja**************@telia.com> writes
"Martin Jay" <ma****@spam-free.org.uk> skrev i meddelandet
news:6X**************@spam-free.org.uk...
In message <11**********************@y43g2000cwc.googlegroups .com>,
AtomicBob <ro**************@gmail.com> writes
>I have been given an interesting task:
>
>Make a page with a single form field, which is to take a name (first
>and last), and regardless of case or whether there is a space between
>the first and last name, when the user hits the submit button it takes
>them to a URL that has been assigned to that name. I've upload something to get your started to:
<http://www.spam-free.org.uk/pages/login.zip>.

It's a bit basic, and you might want to think about what should happen
if someone enters a name that doesn't exist.

What do you think it would happen?


It depends how the server is configured: visitors may get a 'server not
found' error, a 404 error, a default page, or maybe something else.

The script could be modified to deal with unexpected names, either by
looking names up in a database or checking them against a list. Or they
could be hard-coded into it. :(
--
Martin Jay


Do you mean that if an user should fill in a form like this
https://www.scaiecat-spa-gigi.com/sv/formularet.html
and write a name
which does not exist, this user would get a 404 error?!

--
Luigi Donatello Asero
https://www.scaiecat-spa-gigi.com/sv/faktaomitalien.php
今天二零零*年四月二十九日
星期五*

Apr 29 '06 #5
In alt.html, Luigi Donatello Asero wrote:
Do you mean that if an user should fill in a form like this
https://www.scaiecat-spa-gigi.com/sv/formularet.html and write a name
which does not exist, this user would get a 404 error?!


Pay attention, Luigi.

--
-bts
-Warning: I brake for lawn deer
Apr 29 '06 #6
AtomicBob wrote:
Example 1:
user enters "Tony Tiger" in the field and hits submit.
user is then sent to tonytiger.exampledomain.com.

Example 2:
user enters "johnnywalker" in the field and hits submit.
user is then sent to johnnywalker.exampledomain.com.


Unless you use some client-side scripting, a form will always submit to
just one place.

However, that one place could be a script that looks at the form
submission and sends an HTTP 301 redirect to various different places
based on the form contents.

Here's some example code:

<form action="redirect.php" method="get">
<fieldset>
<legend>enter a name</legend>
<input name="name">
<input type="submit">
</fieldset>
</form>

<?php
// This file is "redirect.php".

// What is my domain name?
$mydomain = 'example.com';

// You used 'exampledomain.com' -- you might not have known
// that there exists a domain 'example.com' which is specially
// reserved just for examples.

// What name has the user entered?
$name = $_GET['name'];

// Convert down to lower case
$name = StrToLower($name);

// Remove all characters except 0-9 and a-z
$name = pReg_Replace('/[^0-9a-z]/', '', $name);

// Generate Final URL
$url = "http://{%s}.{$mydomain}/";

// Redirect
Header("HTTP/1.1 301 Redirect");
Header("Location: {$url}");
?>

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Apr 29 '06 #7

"Toby Inkster" <us**********@tobyinkster.co.uk> skrev i meddelandet
news:na************@ophelia.g5n.co.uk...
AtomicBob wrote:
Example 1:
user enters "Tony Tiger" in the field and hits submit.
user is then sent to tonytiger.exampledomain.com.

Example 2:
user enters "johnnywalker" in the field and hits submit.
user is then sent to johnnywalker.exampledomain.com.


Unless you use some client-side scripting, a form will always submit to
just one place.

However, that one place could be a script that looks at the form
submission and sends an HTTP 301 redirect to various different places
based on the form contents.

Here's some example code:

<form action="redirect.php" method="get">
<fieldset>
<legend>enter a name</legend>
<input name="name">
<input type="submit">
</fieldset>
</form>

<?php
// This file is "redirect.php".

// What is my domain name?
$mydomain = 'example.com';

// You used 'exampledomain.com' -- you might not have known
// that there exists a domain 'example.com' which is specially
// reserved just for examples.

// What name has the user entered?
$name = $_GET['name'];

// Convert down to lower case
$name = StrToLower($name);

// Remove all characters except 0-9 and a-z
$name = pReg_Replace('/[^0-9a-z]/', '', $name);

// Generate Final URL
$url = "http://{%s}.{$mydomain}/";

// Redirect
Header("HTTP/1.1 301 Redirect");
Header("Location: {$url}");
?>

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact


How does the file redirect.php file decide to which URL it shall send the
form content?

--
Luigi Donatello Asero
https://www.scaiecat-spa-gigi.com/it/svezia.html
今天二零零*年四月二十九日
星期五*

Apr 29 '06 #8

"Luigi Donatello Asero" <ja**************@telia.com> skrev i meddelandet
news:eD*******************@newsb.telia.net...

"Toby Inkster" <us**********@tobyinkster.co.uk> skrev i meddelandet
news:na************@ophelia.g5n.co.uk...
AtomicBob wrote:
Example 1:
user enters "Tony Tiger" in the field and hits submit.
user is then sent to tonytiger.exampledomain.com.

Example 2:
user enters "johnnywalker" in the field and hits submit.
user is then sent to johnnywalker.exampledomain.com.


Unless you use some client-side scripting, a form will always submit to
just one place.

However, that one place could be a script that looks at the form
submission and sends an HTTP 301 redirect to various different places
based on the form contents.

Here's some example code:

<form action="redirect.php" method="get">
<fieldset>
<legend>enter a name</legend>
<input name="name">
<input type="submit">
</fieldset>
</form>

<?php
// This file is "redirect.php".

// What is my domain name?
$mydomain = 'example.com';

// You used 'exampledomain.com' -- you might not have known
// that there exists a domain 'example.com' which is specially
// reserved just for examples.

// What name has the user entered?
$name = $_GET['name'];

// Convert down to lower case
$name = StrToLower($name);

// Remove all characters except 0-9 and a-z
$name = pReg_Replace('/[^0-9a-z]/', '', $name);

// Generate Final URL
$url = "http://{%s}.{$mydomain}/";

// Redirect
Header("HTTP/1.1 301 Redirect");
Header("Location: {$url}");
?>

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact


How does the file redirect.php file decide to which URL it shall send the
form content?

Do you mean perhaps that it will show a page with 404 error to the user if
he or she has filled in the form a name which contains forbidden
characters?
--
Luigi Donatello Asero
https://www.scaiecat-spa-gigi.com/sv/faktaomitalien.php
今天二零零*年四月二十九日
星期五*

Apr 29 '06 #9
In message <ME*******************@newsb.telia.net>, Luigi Donatello
Asero <ja**************@telia.com> writes
"Martin Jay" <ma****@spam-free.org.uk> skrev i meddelandet
news:vj**************@spam-free.org.uk...
In message <P5*******************@newsb.telia.net>, Luigi Donatello
Asero <ja**************@telia.com> writes
>"Martin Jay" <ma****@spam-free.org.uk> skrev i meddelandet
>news:6X**************@spam-free.org.uk... >> It's a bit basic, and you might want to think about what should happen
>> if someone enters a name that doesn't exist. >What do you think it would happen?
It depends how the server is configured: visitors may get a 'server not
found' error, a 404 error, a default page, or maybe something else.

The script could be modified to deal with unexpected names, either by
looking names up in a database or checking them against a list. Or they
could be hard-coded into it. :(
Do you mean that if an user should fill in a form like this
https://www.scaiecat-spa-gigi.com/sv/formularet.html
and write a name
which does not exist, this user would get a 404 error?!


Swedish? Unfortunately the English version of the page isn't available
yet. :(

My comments were not about forms in general, but specifically about the
setup described by AtomicBob at the beginning of the thread.
--
Martin Jay
Apr 29 '06 #10

"Martin Jay" <ma****@spam-free.org.uk> skrev i meddelandet
news:Fy**************@spam-free.org.uk...
In message <ME*******************@newsb.telia.net>, Luigi Donatello
Asero <ja**************@telia.com> writes
"Martin Jay" <ma****@spam-free.org.uk> skrev i meddelandet
news:vj**************@spam-free.org.uk...
In message <P5*******************@newsb.telia.net>, Luigi Donatello
Asero <ja**************@telia.com> writes
>"Martin Jay" <ma****@spam-free.org.uk> skrev i meddelandet
>news:6X**************@spam-free.org.uk...> It's a bit basic, and you might want to think about what should happen >> if someone enters a name that doesn't exist.What do you think it would happen? It depends how the server is configured: visitors may get a 'server not
found' error, a 404 error, a default page, or maybe something else.

The script could be modified to deal with unexpected names, either by
looking names up in a database or checking them against a list. Or they could be hard-coded into it. :(
Do you mean that if an user should fill in a form like this
https://www.scaiecat-spa-gigi.com/sv/formularet.html
and write a name
which does not exist, this user would get a 404 error?!


Swedish? Unfortunately the English version of the page isn't available
yet. :(

As my one-man business is in Sweden , I usually write the pages in Swedish
first, I often write the pages in Italian ( I am Italian and I was grown up
in Italy
and in German afterwards.....English is not my first priority on the
website.. so I usually write the pages in English later
because there are many more competiting pages in the English language than
for example in Swedish or Finnish or Italian..
Why should I show the content to competitors before I display them to
customers?
(they often understand English...)

My comments were not about forms in general, but specifically about the
setup described by AtomicBob at the beginning of the thread.


Ok.
The thread is interesting anyway....

--
Luigi Donatello Asero
https://www.scaiecat-spa-gigi.com/sv...ancona/numana/
今天二零零*年四月二十九日
星期五*

https://www.scaiecat-spa-gigi.com/sv...ancona/numana/

Apr 29 '06 #11

"Luigi Donatello Asero" <ja**************@telia.com> skrev i meddelandet
news:o1*******************@newsb.telia.net...

"Martin Jay" <ma****@spam-free.org.uk> skrev i meddelandet
news:Fy**************@spam-free.org.uk...
In message <ME*******************@newsb.telia.net>, Luigi Donatello
Asero <ja**************@telia.com> writes
"Martin Jay" <ma****@spam-free.org.uk> skrev i meddelandet
news:vj**************@spam-free.org.uk...
> In message <P5*******************@newsb.telia.net>, Luigi Donatello
> Asero <ja**************@telia.com> writes
> >"Martin Jay" <ma****@spam-free.org.uk> skrev i meddelandet
> >news:6X**************@spam-free.org.uk...
> >> It's a bit basic, and you might want to think about what should happen> >> if someone enters a name that doesn't exist.

> >What do you think it would happen?

> It depends how the server is configured: visitors may get a 'server not> found' error, a 404 error, a default page, or maybe something else.
>
> The script could be modified to deal with unexpected names, either by
> looking names up in a database or checking them against a list. Or they> could be hard-coded into it. :(

Do you mean that if an user should fill in a form like this
https://www.scaiecat-spa-gigi.com/sv/formularet.html
and write a name
which does not exist, this user would get a 404 error?!


Swedish? Unfortunately the English version of the page isn't available
yet. :(

As my one-man business is in Sweden , I usually write the pages in

Swedish first, I often write the pages in Italian ( I am Italian and I was grown up in Italy

I grew up in Italy and I lived some years in Germany. Germany is an
important commercial partner for both Sweden and Italy.
At the same time there are less people speaking for example German, Swedish
and Italian than English...
Not every European speaks Chinese either which is one of the reasons why I
am learning Chinese....
--
Luigi Donatello Asero
https://www.scaiecat-spa-gigi.com/sv...ancona/numana/
今天二零零*年四月二十九日
星期五*
Apr 29 '06 #12
Luigi Donatello Asero wrote:
"Luigi Donatello Asero" <ja**************@telia.com> skrev i meddelandet
news:eD*******************@newsb.telia.net...
"Toby Inkster" <us**********@tobyinkster.co.uk> skrev i meddelandet <snip>
// Convert down to lower case
$name = StrToLower($name);

// Remove all characters except 0-9 and a-z
$name = pReg_Replace('/[^0-9a-z]/', '', $name);

<snip>
Do you mean perhaps that it will show a page with 404 error to the user if
he or she has filled in the form a name which contains forbidden
characters?

Not necessarily. If you look at the function, he is stripping out all
non-alpha numeric characters, if what is left matches a page that exists
then it would be valid else you would get the 404. Of course one would
normally use the cleaned form input and look up from either a listing or
database for the file. If not found it could use a fall-back page with a
Table of Contents of valid filenames/urls.

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Apr 29 '06 #13
This seems a lot easier to me using JavaScript

<html>
<head>
<script>
function redirect()
{
var domain = "exampledomain.com";
var name = document.getElementById("name").value;
name = name.toLowerCase(); //put everthing in lower case
name = name.replace(" ", "");
document.location.href = "http://" + name + "." + domain;
}
</script>
</head>
<body>
Name: <input type="text" id="name" /><br />
<button onclick="javascript:redirect()">Submit</button>
</body>
</html>

May 1 '06 #14
Dustin wrote:
<script>
function redirect()
{
var domain = "exampledomain.com";
var name = document.getElementById("name").value;
name = name.toLowerCase(); //put everthing in lower case
name = name.replace(" ", "");
document.location.href = "http://" + name + "." + domain;
}
</script>


What if the user doesn't have Javascript enabled? Important things like
navigation shouldn't rely on client-side scripting.

What if they type in the name "John O'Groats"? Treat all user input as
hostile by default.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

May 2 '06 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Iain Miller | last post by:
Struggling a bit here & would be grateful for any help. I have a table which has a list of people in it. Each person has a unique ID automatically allocated by Access but also belongs to one of 5...
0
by: Alienz | last post by:
Hey all. if anyone is REALLY bored please help moi. I am new to access stuff and am probably missing something obvious here. I have 2 tables that are linked via "number" in the relationship...
0
by: misscrf | last post by:
I am currently working on a database, in 3rd normal form, which is for candidates who apply for a job with the law firm that I workd for. My issue is with good form design. I have a main...
9
by: MLH | last post by:
I have a database (datatrek.mdb) with a table named DATA. The table has a date/time field with default value = Now(). It has 100 records in it entered over a 50-minute period. I would like the...
2
by: AA Arens | last post by:
Somebody willing to assist me in the following? I want to have values from one field copied to another field when I choose choose a item from a drop down menu. I have 2 forms: 1 Company...
4
by: Nikolay Petrov | last post by:
Hi everyone! I am developing app, which should be used by users, which are members of different groups. These users and groups are stored in my SQL database and are custom for my application,...
2
by: filbennett | last post by:
Hi Everyone, I'm generally unfamiliar with Access form design, but have programmed Cold Fusion applications for a couple of years. I'd like to build a data entry form in Access that allows the...
31
by: DWolff | last post by:
I'm somewhat new to Access, and have no VB experience at all (except for modifying existing code where obvious). I built a data entry form that works fine. Typically, a client will call in and...
2
by: jcf378 | last post by:
hi all. I have a form which contains a calculated control ("days") that outputs the # of days between two dates (DateDiff command between the fields and ). However, when I click "Filter by...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.